当我尝试打印阵列时,我得到“ 0x7ffeedcf3a60”作为输出

时间:2019-10-17 03:11:50

标签: c++

我不确定为什么会这样。任何帮助将不胜感激。

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];
    }
}

1 个答案:

答案 0 :(得分:5)

能否请您说明如何输出阵列?请注意,只需做

cout<<twoDimensional;

输出数组的地址。试试

for (M = 0; M < 4; M++) {
    for (N = 0; N < 3; N++){
        cout << twoDimensional[M][N]<<" ";  
    }
    cout << endl;
}

此代码输出元素的数值。