我不确定为什么会这样。任何帮助将不胜感激。
int M,N;
int const ROW = 4;
int const COLUMN = 3;
int twoDimensional[4][3];
cout << "Welcome to the Matrix Calculator!" << endl;
cout << endl;
cout << "Please enter a " << ROW << "x" << COLUMN << " matrix: " << endl;
cout << endl;
for (M = 0; M < 4; M++) {
cout << endl;
for (N = 0; N < 3; N++){
cout << "Enter Row " << M + 1 << " Column " << N + 1 << ": ";
cin >> twoDimensional[M][N];
}
}
答案 0 :(得分:5)
能否请您说明如何输出阵列?请注意,只需做
cout<<twoDimensional;
输出数组的地址。试试
for (M = 0; M < 4; M++) {
for (N = 0; N < 3; N++){
cout << twoDimensional[M][N]<<" ";
}
cout << endl;
}
此代码输出元素的数值。