it’s my first time using arrays and I’m stuck on this.
How can I change the values inside a 2D array and print it out?
For example, I want to replace the 1s with “” (space) and the 2s with “*” and then print them out. How can i do that?
This is my code:
#include <iostream>
using namespace std;
int main(){
int Xshape[5][5] = {{2,1,1,1,2},
{1,2,1,2,1},
{1,1,2,1,1},
{1,2,1,2,1},
{2,1,1,1,2},
};
{
for (int row = 0; row<5 ; row++)
for (int column=0; column < 5; column++)
{
cout << Xshape[row][column] << endl;
}
}
system("pause");
}
i think it has something to do with the if-else statement but i cant pull it off
can someone help me please?
Yes, it can be done with a simple if-statement: