fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <array>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main(int argc, const char * argv[])
  9. {
  10. array<array<int, 5>, 5> a;
  11. for(int i = 0; i < 5; ++i)
  12. {
  13. for(int j = 0; j < 5; ++j)
  14. {
  15. a[i][j] = rand()%100;
  16. cout << setw(4) << a[i][j];
  17. }
  18. cout << endl;
  19. }
  20.  
  21. cout << "\n\n";
  22. swap(a[1],a[3]);
  23.  
  24. for(int i = 0; i < 5; ++i)
  25. {
  26. for(int j = 0; j < 5; ++j)
  27. {
  28. cout << setw(4) << a[i][j];
  29. }
  30. cout << endl;
  31. }
  32. }
  33.  
  34.  
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
  83  86  77  15  93
  35  86  92  49  21
  62  27  90  59  63
  26  40  26  72  36
  11  68  67  29  82


  83  86  77  15  93
  26  40  26  72  36
  62  27  90  59  63
  35  86  92  49  21
  11  68  67  29  82