标签:quic div return sort code amp 排序 color col
1 void swap(int &i, int &j) 2 { 3 int temp = i; 4 i = j; 5 j = temp; 6 } 7 8 int partition(int a[], int p, int r) 9 { 10 int x = a[r]; 11 int i = p - 1; 12 for (int j = p; j < r; j++) { 13 if (a[j] <= x) { 14 i ++; 15 swap(a[i], a[j]); 16 } 17 } 18 i ++; 19 swap(a[i], a[r]); 20 return i; 21 } 22 23 void quick_sort(int a[], int p, int r) 24 { 25 if (p < r) { 26 int q = partition(a, p, r); 27 quick_sort(a, p, q - 1); 28 quick_sort(a, q + 1, r); 29 } 30 }
标签:quic div return sort code amp 排序 color col
原文地址:https://www.cnblogs.com/ren-yu/p/11869616.html