4.2.1. 별 찍기 - 6 ¶
#백준 2443번 별 찍기 - 6 a=int(input()) for i in range(2*a-1, 0, -2): for j in range(a-int(i/2)-1): print(' ', end='') for j in range(i): print('*', end='') print('')
4.2.2. 별 찍기 - 7 ¶
#백준 2444번 별 찍기 - 7 a=int(input()) for i in range(1, 2*a-1, 2): for j in range(a-int(i/2)-1): print(' ', end='') for j in range(i): print('*', end='') print('') for i in range(2*a-1, 0, -2): for j in range(a-int(i/2)-1): print(' ', end='') for j in range(i): print('*', end='') print('')
4.3.1. 별 찍기 - 6 ¶
n = int(input()) stars = 2 * n - 1 space = 0 for i in range(n): for j in range(space): print(' ', end='') for j in range(stars): print('*', end='') for j in range(space): print(' ', end='') print('\n', end='') stars -= 2 space += 1
4.3.2. 별 찍기 - 7 ¶
n = int(input()) starModifier = 2 stars = 1 for i in range(2 * n - 1): space = (2 * n - 1 - stars) // 2 for j in range(space): print(' ', end='') for j in range(stars): print('*', end='') for j in range(space): print(' ', end='') print('\n', end='') if stars == (2 * n - 1): starModifier = -starModifier stars += starModifier
4.3.3. 별 찍기 - 8 ¶
n = int(input()) starModifier = 1 stars = 1 for i in range(2 * n - 1): space = (n - stars) * 2 for j in range(stars): print('*', end='') for j in range(space): print(' ', end='') for j in range(stars): print('*', end='') print('\n', end='') if stars == n: starModifier = -starModifier stars += starModifier
4.3.4. 별 찍기 - 9 ¶
n = int(input()) stars = 2 *n - 1 starModifier = -2 for i in range(2 * n - 1): space = (2 * n - 1 - stars) // 2 for j in range(space): print(' ', end='') for j in range(stars): print('*', end='') for j in range(space): print(' ', end='') print('\n', end='') if stars == 1: starModifier = -starModifier stars += starModifier