fork download
  1. #include <iostream>
  2. #define M 3
  3. #define N 5
  4. using namespace std;
  5. int n;
  6. int m;
  7. int my_array[N][M];
  8. void print_a(){
  9. cout << "array---------------------------------" << endl;
  10. for (int i = 0; i < n; i++){
  11. for (int j = 0; j < m; j++){
  12. cout << my_array[i][j] << " ";
  13. }
  14. cout << endl;
  15. }
  16. }
  17. int main() {
  18. n = N;
  19. m = M;
  20. int j = n - 1;
  21. for (int i = 0; i < m; i++){
  22. my_array[i][j] = i + j;
  23. print_a();
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
array---------------------------------
0 0 0 
0 4 0 
0 0 0 
0 0 0 
0 0 0 
array---------------------------------
0 0 0 
0 4 0 
0 5 0 
0 0 0 
0 0 0 
array---------------------------------
0 0 0 
0 4 0 
0 5 0 
0 6 0 
0 0 0