fork download
  1. #include <iostream>
  2. #include <random>
  3.  
  4. int main()
  5. {
  6. for( int i = 0 ; i < 10 ; ++i )
  7. {
  8. int seed ; std::cout << "seed? " ; std::cin >> seed ;
  9. std::seed_seq seq( { seed, seed*3+1, seed+101, seed*7+57, seed*11+201 } ) ;
  10. std::mt19937 gen(seq) ;
  11. std::uniform_int_distribution<int> dist( 1, 1000000 ) ;
  12. for( int j = 0 ; j < 10 ; ++j ) std::cout << dist(gen) << ' ' ;
  13. std::cout << '\n' ;
  14. }
  15. }
  16.  
Success #stdin #stdout 0s 2992KB
stdin
1 2 3 4 5 6 7 8 9
stdout
seed? 714952 191559 86080 452371 804233 169070 135378 635753 180852 809736 
seed? 171565 388563 293093 115257 863278 678467 583395 781279 545269 811321 
seed? 339144 322428 880134 147795 501417 994273 124894 576877 342392 970785 
seed? 375064 46686 944101 840313 413267 851395 273631 546716 257518 548637 
seed? 685201 32537 658425 65700 596106 446489 254106 812492 882660 739040 
seed? 596258 736831 633724 435874 971179 728065 243431 742785 757335 822419 
seed? 955763 492071 822365 478931 192786 562018 396316 545094 487116 660079 
seed? 650837 64979 535511 959051 691937 814281 920844 138366 487395 784194 
seed? 397365 873649 210617 986931 371188 571441 344949 779937 119389 863208 
seed? 763969 269265 605432 109346 271514 100521 442687 993683 429546 952705