using System;
namespace ShapeGenerator
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("請輸入圖形類型(1:圓形 2:矩形 3:三角形)");
int shapeType = int.Parse(Console.ReadLine());
switch (shapeType)
{
case 1:
DrawCircle(10);
break;
case 2:
DrawRectangle(10, 10);
break;
case 3:
DrawTriangle(4);
break;
default:
Console.WriteLine("輸入錯誤");
break;
}
}
static void DrawCircle(int radius)
{
int diameter = radius * 2;
for (int i = 0; i < diameter; i++)
{
for (int j = 0; j < diameter; j++)
{
if (Math.Sqrt(Math.Pow(i - radius, 2) + Math.Pow(j - radius, 2)) <= radius)
{
Console.Write("*");
}
else
{
Console.Write(" ");
}
}
Console.WriteLine();
}
}
static void DrawRectangle(int width, int height)
{
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
if (i == 0 || i == height - 1 || j == 0 || j == width - 1)
{
Console.Write("*");
}
else
{
Console.Write(" ");
}
}
Console.WriteLine();
}
}
static void DrawTriangle(int height)
{
for (int i = 0; i < height; i++)
{
Console.WriteLine(new string(' ', height - i - 1) + new string('*', i * 2 + 1));
}
}
}
}