언어 자료구조 알고리즘/프로그래밍 실습
[C# 제어문 실습] 입력한 정수 높이의 삼각형 출력
언제나휴일
2017. 9. 5. 11:42
반응형
[C# 제어문 실습] 입력한 정수 높이의 삼각형 출력
//8. 입력한 정수 높이의 삼각형을 출력
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();
}
}
}
}
반응형