C#/C#200제
[C#] 11일차 - 74. 피라미드 메소드
반나무
2021. 2. 5. 10:51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A074_PyramidMethod
{
class Program
{
static void Main(string[] args)
{
DrawPyramid(3);
DrawPyramid(5);
DrawPyramid(7);
}
static void DrawPyramid(int num)
{
for(int i=1; i<=num; i++)
{
for (int j = i; j < num; j++)
Console.Write(" ");
for (int k = 1; k <= 2 * i -1; k++)
Console.Write("*");
Console.WriteLine();
}
}
}
}
반응형