新手
随便做了下 请指教
static void Square()
{
Console.Write("请输入正方形边长:");
int bc = Int32.Parse(Console.ReadLine());
Console.Write("是否实心:");
string sx = Console.ReadLine();
Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*";
for (int i = 0; i < bc; i++)
{
for (int j = 0; j < bc; j++)
{
if (sx == "Y" || sx == "y")
Console.Write(" "+fh);
if (sx == "N" || sx == "n")
{
if (i == 0 || i == bc - 1 || j == 0 || j == bc - 1)
Console.Write(" " + fh);
else
Console.Write("
");
}
}
Console.WriteLine();
}
}
static void Triangle()
{
Console.Write("请输入三角形边长:");
int bc = Int32.Parse(Console.ReadLine());
Console.Write("是否实心:");
string sx = Console.ReadLine();
Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*";
if (sx == "Y" || sx == "y")
{
for (int i = 0; i < bc; i++)
{
for (int j = 0; j <= bc+ i; j++)
{
if (bc% 2 == 0)
{
if ((i + j) % 2 == 0 && i + j >= bc)
Console.Write("*");
else
Console.Write(" ");
}
else
{
if ((i + j) % 2 == 1 && i + j >= bc)
Console.Write("*");
else
Console.Write(" ");
}
}
Console.WriteLine();
}
}
if (sx == "N" || sx == "n")
{
for (int l = 0; l < bc; l++)
{
for (int k = 0; k < bc + l; k++)
{
if (k + l == bc - 1 || k - l == bc - 1 || l == bc - 1 && k % 2 == 0)
Console.Write(fh);
else
Console.Write(" ");
}
Console.WriteLine();
}
}
}
static void Rectangle()
{
Console.Write("请输入长方形宽:");
int bc = Int32.Parse(Console.ReadLine());
Console.Write("请输入长方形长:");
int kd = Int32.Parse(Console.ReadLine());
Console.Write("是否实心:");
string sx = Console.ReadLine();
Console.Write("选择什么符号表示(回车则为*):");
string fh = Console.ReadLine();
if (fh == "")
fh = "*";
for (int i = 0; i < bc; i++)
{
for (int j = 0; j < kd; j++)
{
if (sx == "Y" || sx == "y")
Console.Write(" " + fh);
if (sx == "N" || sx == "n")
{
if (i == 0 || i == bc - 1 || j == 0 || j == kd - 1)
Console.Write(" " + fh);
else
Console.Write("
");
}
}
Console.WriteLine();
}
}
[[it] 本帖最后由 Y08M09D26 于 2008-10-9 08:48 编辑 [/it]]