課程
/后端開發
/C#
/C#開發輕松入門
這個題怎么做嘛
2017-05-13
源自:C#開發輕松入門 4-10
正在回答
for (int x = 1; x <= 7; x++)//循環7行
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int y = 1; y <= 7; y++)//循環7列
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (x == y || x + y == 8)//對角線打印O
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");//其他位置打印.
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();//換行
? ? ? ? ? ? }
for(int y=1;y<=7;y++) { for(int x=1;x<=7;x++) { if(x==y||x==8-y) { console.write("0"); continue; } console.write("."); } console.writeline(); }
for (int i= 0; i < 7; i++)//循環7行
? ? ? ? ? ? ? ? for (int j = 0; j < 7; j++)//循環7列
? ? ? ? ? ? ? ? ? ? if (i == j || i + i == 6)//對角線打印O
? ? ? ? ? ? ? ? for (int j = 1; j < 7; j++)//循環7列
舉報
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發
2 回答嵌套循環問題
1 回答如何用嵌套for 循環輸出此圖,求解。
1 回答循環嵌套+三元運算符
2 回答for循環
3 回答for循環
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-05-14
for (int x = 1; x <= 7; x++)//循環7行
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int y = 1; y <= 7; y++)//循環7列
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (x == y || x + y == 8)//對角線打印O
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");//其他位置打印.
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();//換行
? ? ? ? ? ? }
2017-05-19
for(int y=1;y<=7;y++)
{
for(int x=1;x<=7;x++)
{
if(x==y||x==8-y)
{
console.write("0");
continue;
}
console.write(".");
}
console.writeline();
}
2017-05-14
for (int i= 0; i < 7; i++)//循環7行
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int j = 0; j < 7; j++)//循環7列
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (i == j || i + i == 6)//對角線打印O
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");//其他位置打印.
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();//換行
? ? ? ? ? ? }
2017-05-14
for (int i= 0; i < 7; i++)//循環7行
? ? ? ? ? ? {
? ? ? ? ? ? ? ? for (int j = 1; j < 7; j++)//循環7列
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (i == j || i + i == 6)//對角線打印O
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write("O");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? Console.Write(".");//其他位置打印.
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine();//換行
? ? ? ? ? ? }