package reverseList; public class Main { static void perm(char c[],int lev,char ans[]) { if(c.length==lev) { System.out.println(String.valueOf(ans)); } else { for(int i=0;i<c.length;i++) { ans[lev]=c[i]; perm(c,lev+1,ans); } } } public static void main(String[] args) { // TODO Auto-generated method stub char c[]="ab".toCharArray(); char ans[]=new char[3]; perm(c,0,ans); } }
ab的排列 aa , ab ba,bb
时间: 2024-10-17 23:56:44