public class Main {
public static void main(String[] args) {
String s = "12345";
char[] c = s.toCharArray();
for (int i = 0; i < c.length; i++) {
char [] cc = new char[i+1];
for (int j = 0; j < cc.length; j++) {
cc[j] = c[j];
}
permutation(0,i,cc);
}
}
private static void permutation(int left, int right, char[] c) {
if(left == right){
System.out.println(new String(c));
}
for (int i = left; i <= right ; i++) {
swap(c,i,left);
permutation(left+1,right,c);
swap(c,i,left);
}
}
private static void swap(char[] c, int left, int right) {
char temp = c[left];
c[left] = c[right];
c[right] = temp;
}
}
最后
以上就是糊涂小海豚最近收集整理的关于全排列应用:输出子集的全部内容,更多相关全排列应用内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复