Advertisement
HyperSensualNarwhal

rnd gen

Jan 10th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. void main()
  6. {
  7.     int arr[10];
  8.     srand(time(NULL));
  9.     for (int i = 0; i < 10; i++)
  10.     {
  11.         if (i == 0) arr[i] = rand() % 15;
  12.         else
  13.         {
  14.             tip:
  15.             arr[i] = rand() % 10;
  16.             for (int j = i; j > 0; j--)
  17.             {
  18.                 if (arr[i] == arr[j-1])
  19.                     goto tip;
  20.             }
  21.         }
  22.     }
  23.     for (int i = 0; i < 10; i++)
  24.     {
  25.         cout << arr[i] << ' ';
  26.     }
  27.     cout << endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement