[C# 제어문 실습] 다이아몬드 출력
[C# 제어문 실습] 다이아몬드 출력
//9. 입력한 정수의 높이에 맞게 다이아몬드를 출력
using System;
namespace 반복문
{
class Program
{
static void Main(string[] args)
{
int line = 0;
line = int.Parse(Console.ReadLine());
int space = 0;
int lcnt = 0;
int star = 0;
for (lcnt = 1; lcnt <= line; lcnt++)
{
for (space = line - lcnt; space > 0; space--)
{
Console.Write(" ");
}
for (star = 1; star <= (2 * lcnt) - 1; star++)
{
Console.Write("*");
}
Console.WriteLine();
}
for (lcnt = line-1; lcnt >=0; lcnt--)
{
for (space = line - lcnt; space > 0; space--)
{
Console.Write(" ");
}
for (star = 1; star <= (2 * lcnt) - 1; star++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
}
}