4.1.1. 별 찍기 - 6 ¶
a = int(input()) for i in range(a): for j in range(2*a-1-i) : if j>=i : print('*', end='') else : print(' ', end='') print('')
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.2.3. 별 찍기 - 8 ¶
#백준 2445 별 찍기 - 8 n=int(input()) mid=2 def printstar(j): for i in range(j): print('*', end='') def printspace(j): for i in range(j): print(' ', end='') for i in range(1, 2*n): if i<=n: printstar(i) printspace(2*(n-i)) printstar(i) print('') else: tmp=i-mid printstar(tmp) printspace(2*(n-tmp)) printstar(tmp) print('') mid+=2
4.2.4. 별 찍기 - 9 ¶
#백준 2446 별 찍기 - 9 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('') for i in range(3, 2*a+1, 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
4.4.1. 별 찍기 - 6 ¶
def blank (n): for i in range (n): print(' ',end = "") def point (n): for i in range (n): print('*',end='') N = int(input()) for i in range(N): blank(i) point(2*N - (2*i +1)) print()
4.4.2. 별 찍기 - 7 ¶
def blank (n): for i in range (n): print(' ',end = "") def point (n): for i in range (n): print('*',end='') N = int(input()) for i in range(N): blank(N - i - 1) point(2*i + 1) print() for i in range(N-1): blank(i + 1) point(2*(N-1) - (2*i+1)) print()
4.4.3. 별 찍기 - 8 ¶
def blank (n): for i in range (n): print(' ',end = '') def point (n): for i in range (n): print('*',end='') N = int(input()) for i in range(1,N+1): point(i) blank(2*N - 2*i) point(i) print() for i in range(1,N): point(N - i) blank(2*i) point(N - i) print()