标签:
while (true) //迭代 要找出规律 看图形各行与各行 (‘‘ "),( "☆")之间的规律
{
Console.Write("请选择您想要得到的图形?A正方形;B三角形;C平行四边形;D菱形;E梯形:");
string n = Console.ReadLine();
Console.Write("请输入数字:");
int m = Convert.ToInt32(Console.ReadLine());
switch (n)
{
case "A":
for (int i = 1; i <= m; i++)
{
Console.Write("☆");
for (int j = 1; j <= m; j++)
{
Console.Write("☆");
}
Console.Write("\n");
}
break;
case "B":
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= m - i; j++)
{
Console.Write(" ");
}
for (int k = 1; k <= 2 * i - 1; k++)
{
Console.Write("☆");
}
Console.Write("\n");
}
break;
case "C":
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <=m-i; j++)
{
Console.Write(" ");
}
for (int k =1; k <= m; k++)
{
Console.Write("☆");
}
Console.Write("\n");
}
break;
case "D":
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= m - i; j++)
{
Console.Write(" ");
}
for (int k = 1; k <= 2 * i - 1; k++)
{
Console.Write("☆");
}
Console.Write("\n");
}
for (int p = 1; p <= m; p++)
{
for (int q = 1; q <= p; q++)
{
Console.Write(" ");
}
for (int h = 1; h <= 2 *(m-p) - 1; h++)
{
Console.Write("★");
}
Console.Write("\n");
}
break;
case "E":
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= m - i; j++)
{
Console.Write(" ");
}
for (int k = 1; k <= 2 * i + 3; k++)
{
Console.Write("☆");
}
Console.Write("\n");
}
break;
default:
Console.Write("您的输入有误!");
break;
}
Console.ReadLine();
}
标签:
原文地址:http://www.cnblogs.com/Mr-xue/p/4423054.html