fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstdlib>
  4. #include <ctime>
  5. int main()
  6. {
  7. std::srand(std::time(NULL));
  8.  
  9. char Grid[5][5] = {'G', 'P', 'W', 'P'};
  10. std::random_shuffle(&Grid[0][0], &Grid[0][0] + 5*5);
  11.  
  12. for(int r = 0; r < 5; ++r)
  13. {
  14. for(int c = 0; c < 5; ++c)
  15. std::cout << (Grid[r][c] ? Grid[r][c] : '_') << ' ';
  16. std::cout << '\n';
  17. }
  18. }
  19.  
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
_ _ P _ _ 
_ _ _ _ _ 
_ _ _ _ _ 
_ _ G W _ 
_ _ _ P _