排序
public static void acm1002(string[] azx) { string[] a = new string[azx.Length]; for (int i = 0; i < azx.Length; i++) { StringBuilder sb = new StringBuilder(); azx[i] = azx[i].Replace("-", ""); for (int j = 0; j < azx[i].Length; j++) { char cr = azx[i][j]; if (cr == 'A' || cr == 'B' || cr == 'C') { sb.Append("2"); } else if (cr == 'D' || cr == 'E' || cr == 'F') { sb.Append("3"); } else if (cr == 'G' || cr == 'H' || cr == 'I') { sb.Append("4"); } else if (cr == 'J' || cr == 'K' || cr == 'L') { sb.Append("5"); } else if (cr == 'M' || cr == 'N' || cr == 'O') { sb.Append("6"); } else if (cr == 'P' || cr == 'R' || cr == 'S') { sb.Append("7"); } else if (cr == 'T' || cr == 'U' || cr == 'V') { sb.Append("8"); } else if (cr == 'W' || cr == 'X' || cr == 'Y') { sb.Append("9"); } else { sb.Append(cr); } } a[i] = sb.ToString(); } int[] items = new int[a.Length]; int bbbb = 0; foreach (var item in a) { items[bbbb] = Convert.ToInt32(item); bbbb++; } QSortDIY(items, 0, items.Length - 1); // Console.WriteLine(string.Join(",", items)); Dictionary<int, int> dic = new Dictionary<int, int>(); foreach (var item in items) { if (!dic.ContainsKey(item)) { dic.Add(item, 1); } else { dic[item]++; } } foreach (var item in dic) { if (item.Value!=1) { string s = item.Key.ToString(); s= s.Insert(3, "-"); Console.WriteLine(s+ " " + item.Value); } } } public static void MPSort(int[] array) { int tep; for (int i = 0; i < array.Length - 1; i++) { for (int j = 0; j < array.Length - i - 1; j++) { if (array[j] > array[j + 1]) { tep = array[j + 1]; array[j + 1] = array[j]; array[j] = tep; } } } } public static void QSortDIY(int[] array, int low, int high) { if (low >= high) { return; } int ie = QSortUnit(array, low, high); QSortDIY(array, low, ie - 1); QSortDIY(array, ie + 1, high); } private static int QSortUnit(int[] array, int low, int high) { int key = array[low]; while (low < high) { while (array[high] >= key && high > low) { --high; } array[low] = array[high]; while (array[low] <= key && high > low) { ++low; } array[high] = array[low]; } array[low] = key; return high; }