Advertisement
Orleon

Untitled

Dec 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1.     srand(time(NULL));
  2.     const int SIZE = 15;
  3.     int mas[SIZE];
  4.     int buf = 0;
  5.  
  6.     for (int i = 0; i < SIZE; ++i) {
  7.         mas[i] = rand() % 1000 - 500;
  8.     }
  9.  
  10.     for (int i = 0; i < SIZE; ++i) {
  11.         cout << mas[i] << " ";
  12.     }
  13.  
  14.     for (int i = 0; i < SIZE - 1; ++i) {
  15.  
  16.         for (int j = i+1; j < SIZE; ++j) {
  17.             if (mas[j] < mas[i]){
  18.                 buf = mas[j];
  19.                 mas[j] = mas[i];
  20.                 mas[i] = buf;
  21.             }
  22.         }
  23.     }
  24.  
  25.     cout << endl;
  26.  
  27.     for (int i = 0; i < SIZE; ++i) {
  28.         cout << mas[i] << " ";
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement