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