必背代码
作者:互联网
快速排序:
1 void quicksort(int left,int right){ 2 int i,j,t,temp; 3 if(left > right) return ; 4 5 temp = aa[left]; 6 i = left, j = right; 7 while(i != j){ 8 while(aa[j] <= temp && i < j) j--; 9 while(aa[i] >= temp && i < j) i++; 10 if(i < j){ 11 t = aa[i]; 12 aa[i] = aa[j]; 13 aa[j] = t; 14 } 15 } 16 aa[left] = aa[i]; 17 aa[i] = temp; 18 19 quicksort(left,i - 1); 20 quicksort(i + 1,right); 21 return; 22 }快速排序
标签:aa,必背,right,temp,int,代码,quicksort,left 来源: https://www.cnblogs.com/rongrongrong/p/14297815.html