using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace day10
{
class Class1
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("请输入你要打印的形状:");
Console.WriteLine("1、方形 2、菱形 3、平行四边形");
Console.Write("你的选择是:");
int x = Convert.ToInt32(Console.ReadLine());
xz(x); //进入选择(xz)函数
//Console.ReadKey();
}
}
static public void lx(int a) //打印菱形
{
for (int i = 1; i <= a; i++)
{
for (int j = 0; j < a-i; j++)
{
Console.Write(" ");
}
for (int k = 0; k < 2*i-1; k++)
{
Console.Write("●");
}
Console.Write("
");
}
for (int i = 1; i <= a; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write(" ");
}
for (int k = 0; k < 2*(a-i)-1; k++)
{
Console.Write("●");
}
Console.Write("
");
}
}
static public void fx(int a ,int b) //打印方形
{
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
Console.Write("★");
}
Console.Write("
");
}
}
static public void px(int a,int b) //打印平行四边形
{
for (int i = 1; i <= a; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write(" ");
}
for (int k = 0; k < b; k++)
{
Console.Write("◆");
}
Console.Write("
");
}
}
static public void xz(int a)
{
switch (a)
{ case 1:
Console.Write("请输入你要打印的方形的高:");
int x = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入你要打印的方形的宽:");
int y = Convert.ToInt32(Console.ReadLine());
fx(x,y);
break;
case 2:
Console.Write("请输入你要打印的菱形的行数:");
int z = Convert.ToInt32(Console.ReadLine());
lx(z);
break;
case 3:
Console.Write("请输入你要打印的平行四边形的高:");
int c = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入你要打印的平行四边形的宽:");
int d = Convert.ToInt32(Console.ReadLine());
px(c,d);
break;
default:
break;
}
} //选择函数
}
}