Advertisement
Unnnamedddd

task

Dec 21st, 2020
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include<iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     setlocale(LC_ALL, "ru");
  9.     srand(time(NULL));
  10.  
  11.     bool flag = false;
  12.     int a;
  13.     int const SIZE = 10;
  14.     int arr[SIZE];
  15.  
  16.     for (int i = 0; i < SIZE; i++)
  17.     {
  18.         a = rand() % 20;
  19.         for (int j = 0; j < i; j++)
  20.         {
  21.             if (arr[j] == a)
  22.             {
  23.                 i--;
  24.                 flag = true;
  25.                 break;
  26.             }
  27.         }
  28.         if (flag == false)
  29.         {
  30.             arr[i] = a;
  31.         }
  32.     }
  33.     for (int i = 0; i < SIZE; i++)
  34.     {
  35.         cout << arr[i] << endl;
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement