日期:2014-05-20 浏览次数:20874 次
private char[][] GetCharCombin(char[] chars) { if (chars.Length == 0) return new char[0][]; List<char[]> list = new List<char[]>(); if (chars.Length == 2) { list.Add(new char[] { chars[0], chars[1] }); list.Add(new char[] { chars[1], chars[0] }); list.Add(new char[] { chars[0], '0' }); list.Add(new char[] { '0', chars[0] }); list.Add(new char[] { chars[1], '0' }); list.Add(new char[] { '0', chars[1] }); list.Add(new char[] { '0', '0' }); } else { for(int i=0,l=chars.Length;i<l;i++) { List<char> charmap = new List<char>(chars); charmap.RemoveAt(i); char[][] charArr = GetCharCombin(charmap.ToArray()); foreach (char[] arr in charArr) { char[] v = new char[arr.Length + 1]; v[0] = chars[i]; for (int i1 = 0, l1 = arr.Length; i1 < l1; i1++) { v[i1 + 1] = arr[i1]; } list.Add(v); } } } return list.ToArray(); }