public class _Test_28_1 {
public static void main(String[] args) {
char [] buf ={'a','b','c'};
perm(buf, 0, buf.length - 1);
}
public static void perm(char[] buf,int start,int end){
if (start == end) {
for (int i = 0; i <= end; i++) {
System.out.print(buf[i]);
}
System.out.println();
}else{
for (int i = start; i <= end; i++) {
char temp = buf[start];
buf[start] = buf[i];
buf[i] = temp;
perm(buf, start + 1, end);
temp = buf[start];
buf[start] = buf[i];
buf[i] = temp;
}
}
}
}
剑指offer:第28题字符串全排列
最新推荐文章于 2024-06-02 17:21:27 发布