#includeusing namespace std; void QuickSort(int* p, int start, int end) { if (start >= end) return; int standard = p[start]; int i = start, j = end - 1; while (i!=j) { for (; p[j] >= standard && j > i; j--); for (; p[i] <= standard && i < j; i++); if (j > i) { int temp = p[i]; p[i] = p[j]; p[j] = temp; } } int temp = p[start]; p[start] = p[i]; p[i] = temp; QuickSort(p, start, i-1); QuickSort(p, i + 1, end); } int main(void) { int n; cout << "请输入待排序的数的个数:"; cin >> n; int* array = new int[n]; cout << "请输入待排序的数:" << endl; for (int i = 0; i < n; i++) { cin >> array[i]; } QuickSort(array, 0, n); cout << "排序完成!排序后的数组为:" << endl; for (int i = 0; i < n; i++) { cout << array[i] << " "; } cout << endl; return 0; }



