标签:
1 void swap(char[] a, int i, int j) 2 { 3 char tmp = a[i]; 4 a[i] = a[j]; 5 a[j] = tmp; 6 } 7 8 void Perm(char[] a, int from, int to) 9 { 10 if(to <=1 ) 11 return; 12 if(from == to) 13 { 14 for(int i = 0; i <= to; i++) 15 System.out.print(a[i]); 16 System.out.println(); 17 } 18 else 19 { 20 for(int j = from; j <= to; j++) 21 { 22 swap(a, j, from); 23 Perm(a, from+1, to); 24 swap(a, j, from); 25 } 26 } 27 }
标签:
原文地址:http://www.cnblogs.com/david-wang/p/4342341.html