刚学C#,不懂正方形输出循环问题,大家帮帮迷途的我啦~~deng
using System;using System.Collections.Generic;
using System.Text;
namespace ZUOYE2
{
class Program
{
static void Main()
{
tuxingchose:
Console.WriteLine("请选择要输出的图形 1.正方形 2.长方形 3.三角形");
string tuxing = Console.ReadLine();
if (tuxing != "1" && tuxing != "2" && tuxing != "3")
{
Console.WriteLine("输入错误!");
goto tuxingchose;
}
if (tuxing == "1")
{
Console.WriteLine("请输入正方形的边长");
int a = Int32.Parse(Console.ReadLine());
if (a <= 0)
{
Console.WriteLine("输入错误!");
}
kongshixin1:
Console.Write("是否实心?按键Y或y为实心,N或n为空心:");
string b = Console.ReadLine();//b为是否为实心
if (b != "y" && b != "Y" && b != "n" && b != "N")
{
Console.WriteLine("输入错误!");
goto kongshixin1;
}
Console.Write("选择什么符号表示(回车则为*):");
string c = Console.ReadLine();//c为图形的符号表示
if (c == "")
c = "*";
for (int i = 0; i < a; i++)----->正方形不是四条边吗?
{
for (int j = 0; j < a; j++)---->怎么只得i和j?输出怎样不是2条边而是四条边?究竟是怎样输出的?搞不懂 {
if (b == "Y" || b == "y")
Console.Write(" " + c);
if (b == "N" || b == "n")
{
if (i == 0 || i == a - 1 || j == 0 || j == a - 1)
Console.Write(" " + c);
else
Console.Write(" ");
}
}
Console.WriteLine();//正方形完毕
}
}
}
}
}
大家帮下忙喇,小弟实菜~~~