fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <random>
  4. #include <chrono>
  5.  
  6. int main()
  7. {
  8. int Tab[4][4]={{1,1,2,2},{3,3,4,4},{5,5,6,6},{7,7,8,8}};
  9. unsigned seed=std::chrono::system_clock::now().time_since_epoch().count();
  10. std::shuffle(&Tab[0][0],&Tab[0][0]+16,std::default_random_engine(seed));
  11. for(int y=0;y<4;++y,std::cout<<std::endl) for(int x=0;x<4;++x) std::cout<<' '<<Tab[y][x];
  12. return 0;
  13. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
 2 7 1 6
 3 5 7 4
 8 6 3 8
 5 4 1 2