fork download
  1. #include <iostream>
  2. #include <random>
  3. #include <vector>
  4.  
  5. std::vector<int> generateRandomArray(std::default_random_engine& generator, int size)
  6. {
  7. std::uniform_int_distribution<int> distribution(1, 100);
  8. std::vector<int> res(size);
  9.  
  10. for (auto& e : res) {
  11. e = distribution(generator);
  12. }
  13.  
  14.  
  15. return res;
  16. }
  17.  
  18. int main()
  19. {
  20. std::default_random_engine generator;
  21. const int size = 10;
  22.  
  23. //first call
  24. for (auto e : generateRandomArray(generator, size)) {
  25. std::cout << e << std::endl;
  26. }
  27.  
  28. std::cout << "------------------" << std::endl;
  29.  
  30. //second call
  31. for (auto e : generateRandomArray(generator2, size)) {
  32. std::cout << e << std::endl;
  33. }
  34. return 0;
  35. }
  36.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:31:39: error: ‘generator2’ was not declared in this scope
     for (auto e : generateRandomArray(generator2, size)) {
                                       ^
stdout
Standard output is empty