编程练习
嵌套循环至少包含 2 层循环,外层的循环体执行一次,内层的循环体则执行 n 次,内层体被执行的总次数 = 内层循环次数 * 外层循环次数。
任务
:::::::::::
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
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();//换行
}
//请完善代码
}
}
}