0

I need help with module 3 of Introduction to C++

I need help when doing the practice of module 3 of Introduction to C++, basically the problem is called Game Map and I can't find a way to complete it, since my code says that it meets 3 requirements but fails in 2, and when I change it then goes the other way around, complies with 2 of the instructions and fails in the other 3 Here I leave my code: #include <iostream> using namespace std; int main() { int map[7][7] = { {0, 0, 1, 1, 0, 1, 0}, {1, 0, 0, 1, 1, 0, 1}, {0, 1, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 0}, {0, 1, 1, 0, 0, 1, 0}, {0, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 0, 0, 1} }; for (int i = 0; i < 2; i++) { for (int j = 0; j < 1; j++) { cout << map[i][j] <<endl; } } }

24th Nov 2023, 1:26 AM
Fabrizio Antonio Franco Tami
Fabrizio Antonio Franco Tami - avatar
2 Respuestas
+ 3
Fabrizio Antonio Franco Tami I believe that the tests ... requires two inputs not two for loops So initialize two variable int num1, num2; Then allow the test to: cin >> num1 >> num2; Then output based on the variables: cout << map[num1][num2] << endl;
24th Nov 2023, 4:33 AM
BroFar
BroFar - avatar
0
there's no need for the for loops just use: int i; int j; cin >> i >> j; cout << map[i][j];
28th Mar 2024, 10:43 AM
Callum
Callum - avatar