namespace NoRepeatArray { class Program { static void Main(string[] args) { int[] testArray_1 = { 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 17, 18, 19, 20, 21, 25, 24, 21, 32 }; int[] testArray_2 = { 20, 32, 25, 21, 25, 36, 37, 38, 39, 10, 100, 21, 32, 1000, 999, 1000, 200, 45 }; int[] testArray_3 = { 10, 15, 20, 15 }; int start_1 = 0; int start_2 = 0; int start_3 = 0; int end_1 = testArray_1.Length - 1; int end_2 = testArray_2.Length - 1; int end_3 = testArray_3.Length - 1; QuickSort quickSort1 = new QuickSort(testArray_1); quickSort1.sort(testArray_1, start_1, end_1); //quickSort1.print(); Judgment judgment1 = new Judgment(testArray_1); judgment1.judgment(); judgment1.print(); Console.WriteLine(); QuickSort quickSort2 = new QuickSort(testArray_2); quickSort2.sort(testArray_2, start_2, end_2); Judgment judgment2 = new Judgment(testArray_2); judgment2.judgment(); judgment2.print(); Console.WriteLine(); QuickSort quickSort3 = new QuickSort(testArray_3); quickSort3.sort(testArray_3,start_3,end_3); Judgment judgment3 = new Judgment(testArray_3); judgment3.judgment(); judgment3.print(); } } class QuickSort { int[] array; public QuickSort(int[] _array) { this.array = _array; } public int partiton(int[] _array, int _start, int _end) { int start = _start; int end = _end; while (start < end) { while ((start < end) && (_array[start] <= _array[end])) { end--; } if (start < end) { int temp = _array[start]; _array[start] = _array[end]; _array[end] = temp; start++; } while ((start < end) && (_array[start] <= _array[end])) { start++; } if (start < end) { int temp = _array[start]; _array[start] = _array[end]; _array[end] = temp; end--; } } return start; } public void sort(int[] _array, int start, int end) { if (start < end) { int pivot = partiton(_array, start, end); sort(_array, start, pivot - 1); sort(_array, pivot + 1, end); } } public void print() { for (int i = 0; i < array.Length; i++) { Console.Write(array[i]); Console.Write(" "); } Console.WriteLine(); } } class Judgment { int[] array; StringBuilder strArray = new StringBuilder(); public Judgment(int[] _array) { this.array=_array; } public void judgment() { for (int i = 1; i < array.Length-1; i++) { if ((i == 1) && (array[i] != array[i - 1])) { strArray.Append(array[i - 1]); strArray.Append(" "); } else if ((array[i] != array[i + 1])&&(array[i-1]!=array[i])) { strArray.Append(array[i]); strArray.Append(" "); } else if ((i == array.Length - 2) && (array[i + 1] != array[i])) { strArray.Append(array[i + 1]); } } } public void print() { string result = strArray.ToString(); Console.WriteLine(result); } } }