package com.test.paixu;
public class MyPaixu {
public void paixu(char[] a,String tempStr){
for(int i=0;i<a.length;i++){
String temp = tempStr;
if(1==a.length){
temp+=a[0];
System.out.println(temp);
break;
}
char[] tempChar = new char[a.length-1];
int t=0;
temp+=a[i];
for(int j=0;j<i;j++){
tempChar[t]=a[j];
t++;
}
for(int j=i+1;j<a.length;j++){
tempChar[t]=a[j];
t++;
}
paixu(tempChar,temp);
}
}
public MyPaixu(){
String str = "abcd";
char[] ch = str.toCharArray();
paixu(ch,"");
}
public static void main(String[] args){
new MyPaixu();
}
}
posted on 2010-04-27 12:04
fzllcc 阅读(134)
评论(0) 编辑 收藏