快排
链接:http://blog.csdn.net/morewindows/article/details/6684558
写得很清楚
int sort(int s,int f){ int x = s; int y = f+1; int stemp = numbers[s]; while(1){ while(numbers[++x] < stemp); while(numbers[--y] > stemp); if(x>=y) break; int swap = numbers[x]; numbers[x] = numbers[y]; numbers[y] = swap; } numbers[s] = numbers[y]; numbers[y] = stemp; return y; } void quick(int s,int f){ if(s<f){ int m = sort(s,f); quick(s, m-1); quick(m+1, f); } }