這樣不行嗎?
?for(int i=1;i<=7;i++)
??????????? {
??????????????? for(int j=1;j<=7;j++)
??????????????? {
??????????????? int x=1;
??????????????? int y=7;
????????????????? if(j==x||j==y)
????????????????? Console.Write("O");
????????????????? else
????????????????? Console.Write(".");
????????????????? x++;
????????????????? y--;
??????????????? Console.WriteLine();
??????????? }
2017-07-13
內(nèi)循環(huán)是打印一行的字符,你定義的x在內(nèi)循環(huán)里自加,對應(yīng)的是該行里的每一個字符,跟for循環(huán)的自加就是一樣,這樣j就恒等于x,條件表達式恒為真,打印的每一個字符都是o
2017-07-13
??????? for(int x=1;x<8;x++)
??????????? {
??????????????? for(int y=1; y<8;y++)
??????????????? {
??????????????????? if(y==x||(x+y==8&&x!=4))
??????????????????? Console.Write("o");
??????????????????? else
??????????????????? Console.Write(".");
??????????????? }
??????????????? Console.WriteLine();
??????????? }
2017-07-13
for(int x=1;x<=7;x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for(int y=1;y<=7;y++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if(y==x||y==8-x)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("o");
? ? ? ? ? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ?Console.WriteLine(" ");
? ? ? ? ? ? }//請完善代碼
2017-07-13
? ? ? ? ? ? int x = 1;
? ? ? ? ? ? int y = 7;
? ? ? ? ? ? for (int i = 1; i <= 7; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int j = 1; j <= 7; j++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (j == x || j == y)
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("0");
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? x++;
? ? ? ? ? ? ? ? y--;
? ? ? ? ? ? ? ? Console.WriteLine(" ");
? ? ? ? ? ? }//請完善代碼