算法学习-快速排序(QUICK SORT)

xiaoxiao2021-02-28  16

void QUICKSORT(int a[], int p, int r) { int q = PARTITION(a, p, r); QUICKSORT(a, p, q - 1); QUICKSORT(a, q + 1, r); } int PARTITION(int a[], int p, int r) { int i = p - 1; for (int j = 0; j < r; j++) { if (a[j] < a[r]) { i++; a[i] = a[j]; } else a[i] = a[r]; } return i + 1; }
转载请注明原文地址: https://www.6miu.com/read-1950133.html

最新回复(0)