1 #include2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int main() 8 { 9 srand(unsigned(time(0))); 10 freopen("random1.txt","w",stdout); 11 for(int i = 0 ; i < 1000 ; i++) 12 { 13 int a = rand() % 100; 14 cout<< a <<" "; 15 } 16 fclose(stdout); 17 18 } 19 #include 20 #include 21 #include 22 #include 23 #include 24 using namespace std; 25 int fuzhukuaipai(int a[],int i,int j) 26 { 27 int key = a[i]; 28 while(i =key&&i a[j])swap(a[i],a[j]); 78 } 79 } 80 } 81 int main() 82 { 83 int a[100000] ; 84 ifstream fin; 85 fin.open("random_number.txt"); 86 for(int i = 0 ; i < 100000 ; i++) 87 { 88 fin>>a[i]; 89 } 90 fin.close(); 91 time_t Start; 92 time_t End; 93 Start = clock(); 94 // QuickSort(a,0,100000); 95 kuaipai(a,0,100000); 96 End = clock(); 97 cout<<"kuaipai-spend:"< < >a[i];108 }109 fin.close();110 Start = clock();111 QuickSort(a,0,100000);112 End = clock();113 cout<<"QuickSort-spend:"< < >a[i];120 }121 fin.close();122 Start = clock();123 sort(a,a+100000);124 End = clock();125 cout<<"Sort-spend:"< <