Advertisement
tills

selection sort2

Nov 17th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <vector>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. void zmiany()
  9. {
  10.         for(int i=0; i<ile_liczb; i++)
  11.     {
  12.         cout << losowe[i] << " " ;
  13.     }
  14.     cout << endl;
  15.    
  16. }
  17.  
  18. int main()
  19. {
  20.     cout << "Ile liczb chcesz wylosowac: ";
  21.     int ile_liczb {0};
  22.     cin >> ile_liczb;
  23.    
  24.     srand(time(NULL));
  25.  
  26.    
  27.     vector<int> losowe;
  28.     for(int i=0; i < ile_liczb ; i++)
  29.     {
  30.         int b = rand() % 99+1;
  31.         losowe.push_back(b);
  32.         cout << losowe.at(i)<< " ";
  33.     }
  34.    
  35.     for(int i=0; i < ile_liczb-1 ; i++)
  36.     {if(losowe[i+1] < losowe[i])
  37.         {
  38.             swap(losowe[i], losowe[i+1]);
  39.         }
  40.     }  
  41.    
  42.     cout << "\n";
  43.    
  44.  
  45.    
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement