+ 3

Help please with this code.

int main () { int a[6][7]; for (int x = 0; x < 6; x++ ){ cin >> a[x]; } for (int y = 0; y < 7; y++){ cin >> a[y]; } return 0; }

25th Apr 2017, 5:45 AM
Mr. Hordik
Mr. Hordik - avatar
3 Answers
+ 12
You have a 2D array, but you're operating it the 1D way. In order to fill it up, you have to combine two loops. int main () { int a[6][7]; for (int x = 0; x < 6; x++ ){ for (int y = 0; y < 7; y++){ cin >> a[x][y]; } } return 0; }
25th Apr 2017, 5:49 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
what's the problem?
25th Apr 2017, 5:46 AM
Mario L.
Mario L. - avatar
+ 2
thx, it helps.
25th Apr 2017, 5:57 AM
Mr. Hordik
Mr. Hordik - avatar