Advertisement
Guest User

Untitled

a guest
May 24th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int tab[5];
  9.     srand(time(NULL));
  10.     for (int i = 0; i < 5; i++)
  11.         {
  12.             tab[i] = rand() % (50) + 1;
  13.             for (int o = 0; o < i; o++)
  14.             {          
  15.                 while (tab[o] == tab[i])
  16.                 {
  17.                     tab[i] = rand() % (50) + 1;
  18.                 }
  19.             }
  20.         }
  21.     cout << "Wylosowane liczby: " << endl;
  22.     for (int i = 0; i < 5; i++)
  23.     {
  24.         cout << tab[i]<<endl;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement