這是我第一次使用數組,我堅持這一點。 如何更改2D數組內的值並將其打印出來?打印出二維數組,取代數值
例如,我想用「」(空格)替換1並將「2」替換爲「
*
」,然後將其打印出來。我怎樣才能做到這一點?
這是我的代碼:
#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");
}
我覺得它有什麼做的if-else語句,但我不能把它關閉 有人可以幫助我嗎?
埃姆.....什麼if-else語句? – Bart
您介意向我們展示您嘗試過的if-else語句嗎? –
您不僅沒有'if..else'語句,而且您也不想替換任何東西。 –