fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. srand(time(NULL));
  10.  
  11. const int SIZE=10;
  12.  
  13. int randArray[SIZE];
  14.  
  15. int random;
  16. int table[SIZE];
  17.  
  18. for (int i = 0; i < SIZE; ++i)
  19. {
  20. for(bool exists;; )
  21. {
  22. exists = false;
  23. random = rand();
  24. for(int j = 0; j<i; j++)
  25. {
  26. if (table[j] == random)
  27. {
  28. exists = true;
  29. break;
  30. }
  31. }
  32. if (!exists) break;
  33. }
  34. cout << (randArray[i]=random) << endl;
  35. }
  36. }
  37.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
1871979857
214589917
133321856
1567404471
1798495965
1847361195
9572227
332920727
73463265
1502294320