标签:java os for ar har 递归 public print
/** * @param args */ public static void main(String[] args) { char[] raw = "12345".toCharArray(); perm(raw, 4); // System.out.println("==========================="); // System.out.println(Arrays.toString(raw)); } static void perm(char[] data, int k) { if (k == 0) { System.out.println(Arrays.toString(data)); } else { for (int i = 0; i <= k; i++) { char t = data[i]; data[i] = data[k]; data[k] = t; perm(data, k - 1); t = data[i]; data[i] = data[k]; data[k] = t; } } }
标签:java os for ar har 递归 public print
原文地址:http://my.oschina.net/u/189899/blog/296451