Advertisement
Joporezka1

Untitled

Apr 20th, 2022
727
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. void selectionSort(int *arr, int n)
  2. {
  3.     for (int i = 0; i < n - 1; i++)
  4.     {
  5.         int min_id = i;
  6.  
  7.         for (int j = i + 1; j < n; j++){
  8.             if (arr[j] < arr[min_id])
  9.                 min_id = j;
  10.         }
  11.         int temp = arr[min_id];
  12.         arr[min_id] = arr[i];
  13.         arr[i] = temp;
  14.         //if(i%10000==0) cout<<"Selection sort: "<<i<<"/"<<n<<endl;
  15.  
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement