所以我在網上看,看到其他方式來創建一個tic toe表,但我不明白這一點。我試圖用一個數組來創建我的tic tac toe板,但我似乎無法打印它。有人可以告訴我如何打印?如何打印包含tic tac toe遊戲板的陣列?
string tic [6][5] = { {" 1 2 3"}, { "1 | | "}, {" _____"}, {"2 | | " }, {" _____"},
{"3 | | "}};
cout<< tic<< endl ;
a++;
每個人都有自己的做事方式。我只是想知道爲什麼不打印出來。
好吧,這就是我的代碼現在看起來如此,以便我可以輸入X和O但它似乎不打印到一行。
int a = 0;
while (a < rounds){
string tic [6][6] = { {" ","1"," ","2"," ","3"}, { "1"," ","|"," ","|"," "}, {" ","_","_","_","_","_"}, {"2"," ","|"," ","|"," " }, {" ","_","_","_","_","_"},{"3"," ","|"," ","|"," "}};
for(int i=0; i < 6; ++i)
for(int j=0; j<6; ++j)
cout << tic[i][j];
a++;
你熟悉循環嗎? –
我是?但我需要使用這些字符? – Monrelle
有沒有,但!如果你想打印一個二維數組,你必須使用循環 –