/*
* 答应出abc的所有组合
* 按角标打印
* 每个角标对应的字符,角标不相同则打印
*
*
* */
public static void main(String[] args) {
// TODO Auto-generated method stub
pailie("abc");
}
public static void pailie(String str){
int a;
for(int i=0;i<str.length();i++){
for(int j=0;j<str.length();j++){
for(int k=0;k<str.length();k++){
if(i!=j&&i!=k&&j!=k){
System.out.print(str.subSequence(i, i+1));
System.out.print(str.subSequence(j, j+1));
System.out.print(str.subSequence(k, k+1));
System.out.println("");
}
}
if(i!=j){
System.out.print(str.subSequence(i, i+1));
System.out.print(str.subSequence(j, j+1));
//System.out.print(str.subSequence(k, k+1));
System.out.println("");
}
}
System.out.print(str.subSequence(i, i+1));
System.out.println("");
}
}
}
|
|