with the following code:
#include <iostream>
#define M 3
#define N 5
using namespace std;
int n;
int m;
int my_array[N][M];
void print_a(){
cout << "array---------------------------------" << endl;
for (int i = 0; i < m; i++){
for (int j = 0; j < n; j++){
cout << my_array[i][j] << " ";
}
cout << endl;
}
}
int main() {
n = N;
m = M;
int j = n - 1;
for (int i = 0; i < m; i++){
my_array[i][j] = i + j;
print_a();
}
return 0;
}
array---------------------------------
0 0 0 0 4
0 4 0 0 0
0 0 0 0 0
array---------------------------------
0 0 0 0 4
0 4 0 0 5
0 5 0 0 0
array---------------------------------
0 0 0 0 4
0 4 0 0 5
0 5 0 0 6
tow cells in the double array are changed. I know that double array is also single array. so, even the col and row are exchanged. there should not be two cells are changed. It's Why?