Advertisement
Zhobra

Untitled

Jul 10th, 2023
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | Source Code | 0 0
  1. int main() {
  2.     setlocale(0, "");
  3.     int i;
  4.     int* arr = new int[MAX];
  5.  
  6.     srand(time(NULL));
  7.     for (int i = 0; i < MAX; i++)
  8.     {
  9.         arr[i] = MAX - i;
  10.  
  11.         //  cout << arr[i] << " ";
  12.     }
  13.     //  for (i = 0; i < MAX; i++)
  14.         //  arr[i] = i + 1;
  15.     start = clock();
  16.     random_shuffle(arr); //To randomize the array
  17.     quick_sort(arr, 0, MAX - 1); //sort the elements of array
  18.     //  for (i = 0; i < MAX; i++)
  19.         //  cout << arr[i] << " ";
  20.     cout << endl;
  21.     timing = (float)(clock() - start) / CLOCKS_PER_SEC;
  22.  
  23.     delete[] arr;
  24.     cout << "Время сортировки массива = " << timing;
  25.     cout << endl;
  26.     system("pause");
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement