public static void swapChar(char[] str ,int i,int j){ char tmp = str[i]; str[i] = str[j]; str[j] = tmp; } public static void printString(char[] str,int low,int high){ int i; char tmp; if(low == high){ System.out.println(str); }else{ for(i=low;i<high;i++ ){ swapChar(str,low,i); printString(str,low+1,high); swapChar(str,low,i); } } }
对递归的理解,这里的字符串没有重复字符。
时间: 2024-10-10 13:57:32