Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

아보카도 Blog

프로그래머스 스쿨 코딩테스트 입문: 직각삼각형 출력하기 본문

자료구조, 알고리즘

프로그래머스 스쿨 코딩테스트 입문: 직각삼각형 출력하기

수수 아보카도 2022. 12. 22. 15:55

별찍기 문제다. 문제 출처

자바때는 중첩반복문으로 풀었다.

파이썬으로 풀때도 비슷하게 풀었다.

n = int(input())
output = ""

for i in range(0,n):
    for j in range(0,i+1):
        output += "*"
    output += "\n"

print(output)

근데 더 간단한 방법이 있어 올려본다.

n = int(input())
for i in range(n):
    print('*'*(i+1))