課程
/后端開發(fā)
/C#
/C#開發(fā)輕松入門
兩個for為什么一個是代表行一個是代表列呢?
2018-04-27
源自:C#開發(fā)輕松入門 4-10
正在回答
內(nèi)層的for用于輸出.和o 外層只用來換行
愛學習的小張 提問者
for (int x = 1; x <=7 ; x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ?for (int y = 1; y <=7 ; y++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if(x==y || x+y == 8)
? ? ? ? ? ? ? ? ? ? ? ? Console.Write('O');
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? Console.Write('.');
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? }
?for(int x =1;x<=7;x++)
? ? ? ? ? ? ? ? for(int y =1;y<=7;y++)
? ? ? ? ? ? ? ? ? ? if(y==x||y==7-x+1)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ??
? ? ? ? ? ? ? ? Console.WriteLine("");
舉報
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發(fā)
1 回答一個搞不懂的問題
3 回答不明白哪里寫的不對
3 回答4-10的題不會做,求解
1 回答這樣不是更快?少了一個for
2 回答4-10
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-05-11
內(nèi)層的for用于輸出.和o
外層只用來換行
2018-05-21
for (int x = 1; x <=7 ; x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ?for (int y = 1; y <=7 ; y++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if(x==y || x+y == 8)
? ? ? ? ? ? ? ? ? ? ? ? Console.Write('O');
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? Console.Write('.');
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();
? ? ? ? ? ? }
2018-04-27
?for(int x =1;x<=7;x++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for(int y =1;y<=7;y++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if(y==x||y==7-x+1)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine("");
? ? ? ? ? ? }