fork(2) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <array>
  4. #include <random>
  5. #include <functional>
  6. #include <algorithm>
  7. using namespace std;
  8.  
  9. int main() {
  10. // your code goes here
  11. std::array<float, 10> x;
  12. std::array<float, 10> y;
  13.  
  14. std::random_device rd;
  15. std::mt19937_64 gen(rd());
  16. std::uniform_real_distribution<float> dis(-1.f, 1.f);
  17. auto rand = std::bind(dis, gen);
  18. std::generate(x.begin(), x.end(), rand);
  19. std::generate(y.begin(), y.end(), rand);
  20.  
  21. for (size_t i = 0; i < x.size(); ++i)
  22. {
  23. std::cout << std::setw(3) << i << ": ";
  24. std::cout << std::setw(10) << x[i] << ", "
  25. << std::setw(10) << y[i] << std::endl;
  26. }
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
  0:  -0.411968,  -0.411968
  1:    0.55158,    0.55158
  2:    0.69889,    0.69889
  3:  -0.901328,  -0.901328
  4:  -0.556142,  -0.556142
  5:  -0.798431,  -0.798431
  6:  -0.570874,  -0.570874
  7:   0.928999,   0.928999
  8:   0.118056,   0.118056
  9:  -0.655123,  -0.655123