fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. void func(int a[5][5])
  7. {
  8. for(int i = 0; i < 5; ++i) {
  9. for(int j = 0; j < 5; ++j)
  10. cout << setw(3) << (a[i][j] = 7 - a[i][j]);
  11. cout << "\n";
  12. }
  13. }
  14.  
  15.  
  16. int main()
  17. {
  18. srand(time(0));
  19. int arr[5][5];
  20. for(int i = 0; i < 5; ++i) {
  21. for(int j = 0; j < 5; ++j)
  22. cout << setw(3) << (arr[i][j] = rand()%4+2);
  23. cout << "\n";
  24. }
  25.  
  26. cout << "\n\n\n";
  27.  
  28. func(arr);
  29.  
  30. cout << "\n\n\n";
  31.  
  32.  
  33. // Чтоб убедиться
  34. for(int i = 0; i < 5; ++i) {
  35. for(int j = 0; j < 5; ++j)
  36. cout << setw(3) << arr[i][j];
  37. cout << "\n";
  38. }
  39.  
  40. }
  41.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
  3  2  5  2  2
  2  4  2  3  4
  5  2  3  5  5
  5  4  4  2  4
  4  3  5  5  3



  4  5  2  5  5
  5  3  5  4  3
  2  5  4  2  2
  2  3  3  5  3
  3  4  2  2  4



  4  5  2  5  5
  5  3  5  4  3
  2  5  4  2  2
  2  3  3  5  3
  3  4  2  2  4