fork download
  1. #include <iostream>
  2. #include <random>
  3. #include <chrono>
  4. #include <vector>
  5. #include <algorithm>
  6.  
  7. int main()
  8. {
  9. auto seed = std::chrono::system_clock::now().time_since_epoch().count();
  10. std::default_random_engine engine( seed );
  11. std::uniform_int_distribution<int> distribution( 0, 99 );
  12. auto generator = [&] { return distribution( engine ); };
  13.  
  14. std::vector<int> randoms;
  15. while( randoms.size() < 30 )
  16. {
  17. auto newNumber = generator();
  18. if( std::find( randoms.begin(), randoms.end(), newNumber ) == randoms.end() )
  19. {
  20. randoms.emplace_back( newNumber );
  21. }
  22. }
  23.  
  24. for( auto&& number : randoms ) std::cout << number << "\n";
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
16
43
4
54
49
39
15
92
37
3
31
23
5
73
74
28
96
64
89
8
38
68
84
98
65
97
83
79
10
69