반응형
깃 링크 : 바로가기
링크 : 바로가기
1차시도
using System.Text;
public class num_2438
{
public static void Main()
{
int max = Convert.ToInt32(Console.ReadLine());
StringBuilder result = new StringBuilder();
for (int i = 0; i < max; i++)
{
for (int x = 0; x < i + 1; x++)
{
result.Append("*");
}
result.Append("\n");
}
Console.WriteLine(result.ToString());
}
}
결과

- 이중 for문을 이용해서 i횟수만큼 "*"을 추가하고 두번째 for문을 빠져나올때 "\n"로 줄바꿈 후 출력
반응형
'기타 > 코딩테스트 공부' 카테고리의 다른 글
[백준] A+B(5) - 10952번 (0) | 2025.05.01 |
---|---|
[백준] 별찍기(2) - 2439번 (0) | 2025.05.01 |
[백준] A+B-8 - 11022번 (0) | 2025.05.01 |
[백준] A+B-7 - 11021번 (0) | 2025.05.01 |
[백준] 빠른 A+B - 15552번 (0) | 2025.05.01 |