Files
CodeObject/storage/zeta/py/2448.py

64 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
2448: 별 찍기 - 11
문제:
예제를 보고 규칙을 유추한 뒤에 별을 찍어 보세요.
입력:
첫째 줄에 N이 주어진다. N은 항상 3×2^k 수이다. (3, 6, 12, 24, 48, ...) (k ≤ 10)
출력:
첫째 줄부터 N번째 줄까지 별을 출력한다.
"""
"""
TC1:
Input:
24
Output:
*
* *
*****
* *
* * * *
***** *****
* *
* * * *
***** *****
* * * *
* * * * * * * *
***** ***** ***** *****
* *
* * * *
***** *****
* * * *
* * * * * * * *
***** ***** ***** *****
* * * *
* * * * * * * *
***** ***** ***** *****
* * * * * * * *
* * * * * * * * * * * * * * * *
***** ***** ***** ***** ***** ***** ***** *****
"""
s = [" * ", " * * ", "***** "]
def makestar(shift):
global s
c = len(s)
for i in range(c):
s.append(s[i] + s[i]) # 현 단계 삼각형을 뒤에 붙이고
print(s)
s[i] = (" " * shift + s[i] + " " * shift) # 현 단계 삼각형을 오른쪽으로 민다
print(s)
n = int(input())
k= n//6
for i in range(k):
print(int(pow(2,i)))
makestar(int(pow(2, i)))
for i in range(n):
print(s[i])
print(s)
print(k)