fork download
  1. #include <iostream>
  2. #include <random>
  3.  
  4. int main() {
  5. std::random_device rd;
  6. std::uniform_int_distribution<> dis(0,1);
  7. const int N = 100;
  8. int v = 0;
  9. for( int i=0; i<N; ++i )
  10. {
  11. std::cout << v << " ";
  12. v += dis(rd) ? 1 : -1;
  13. }
  14. std::cout << std::endl;
  15.  
  16. // your code goes here
  17. return 0;
  18. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
0 -1 -2 -3 -4 -5 -4 -3 -2 -1 -2 -3 -4 -3 -2 -1 -2 -1 0 -1 0 -1 -2 -3 -4 -5 -6 -5 -4 -5 -4 -5 -4 -3 -4 -5 -6 -5 -6 -7 -6 -7 -8 -9 -10 -11 -10 -9 -10 -11 -10 -9 -8 -7 -6 -7 -6 -5 -4 -5 -4 -5 -6 -5 -6 -5 -4 -3 -2 -1 0 -1 -2 -3 -2 -1 -2 -1 -2 -3 -4 -3 -2 -3 -2 -1 0 1 2 3 4 5 4 5 4 3 4 3 2 3