标签:class blog code 2014 string os
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <string> #include <algorithm> #include <queue> using namespace std; int num[9] = {7,10,19,25,12,17,21,30,48}; void quicksort(int sta,int ed){ int i = sta,j = ed,x = num[sta]; while(i < j){ while(num[j] >= x&&j > i) j--; if(j > i){ num[i] = num[j]; i++; } while(num[i] < x&&j > i) i++; if(j > i){ num[j] = num[i]; j--; } } num[i] = x; if(sta<i-1) quicksort(sta,i-1); if(i+1<ed) quicksort(i+1,ed); } int main(){ quicksort(0,8); for(int i = 0; i <= 8; i++){ cout<<num[i]<<endl; } return 0; }
标签:class blog code 2014 string os
原文地址:http://blog.csdn.net/mowayao/article/details/31390033