ํ์ด์ฌ์ ๊ธฐ์ด๋ถํฐ ์์ํ๋ค๋ณด๋ฉด ์์กฐ๋กญ๊ฒ ์งํํ๋ค๊ฐ for๋ฌธ์ ๋ฐฐ์ฐ๋ฉด์ "๋ณ ์ฐ๊ธฐ"์ ๋์ ํ๊ฒ ๋๋ค.
์ฌ๊ธฐ์ ๋๋ถ๋ถ ์ฒ์ '์ฝ๋ฉ์ ๋ด ๊ธธ์ด ์๋๊ฐ' ํ๊ณ ์๊ฐํ๊ฒ ๋๋ ๊ฒ ๊ฐ๋ค.
๊ทธ๋ฌ๋ ๋๊ตฌ๋ ์ฒ์ฒํ ์ฝ๋๋ฅผ ์ดํด๋ณด๋ฉด ์ดํดํ ์ ์๋ค๐ฅ
์ ๋ง ์ฌ์ด ๊ธฐ์ด๋ถํฐ ์ฝ๊ฐ ๊ณ ๋ฏผํด์ผ๋๋ 10๊ฐ์ง ๋ชจ์์ ๋ณ ์ฐ๊ธฐ๋ฅผ ์ค๋นํ๋ค.
** Python ์ฝ๋
# 1
for i in range(5):
print("*")
# 2
print("*" * 5)
# 3
for i in range(5):
print("*" * 5)
# 4
for i in range(5):
print((i+1) * "*")
# 5
for i in range(5,0,-1):
print("*"*i)
#6
for i in range(5):
for j in range(4-i):
print(" ",end="")
for j in range(i+1):
print("*",end="")
print()
# 7
for i in range(5):
for j in range(i):
print(" ",end="")
for j in range(5-i):
print("*",end="")
print()
# 8
for i in range(5):
for j in range(4-i):
print(" ",end="")
for j in range(2*(i+1)-1):
print("*",end="")
print()
# 9
for i in range(5,0,-1):
for j in range(5-i):
print(" ",end="")
for j in range(2*i-1):
print("*",end="")
print()
# 10
for i in range(1,10):
if i <= 5:
for j in range(5-i):
print(" ",end="")
for j in range(2*i-1):
print("*",end="")
print()
else:
for j in range(i-5):
print(" ",end="")
for j in range((10-i)*2-1):
print("*",end="")
print()
โ ์ซ์๋ฅผ ๊ณ ์ ์ํจ์ฑ๋ก ์ฝ๋๋ฅผ ์งฐ๋๋ฐ ์ฌ์ฉ์์๊ฒ ์ ๋ ฅ ๋ฐ์ ์์ฑํ๋ ์ฝ๋๋ก ์์ ํ๋ฉด ์ข์ ๊ฒ ๊ฐ๋ค!
๋๊ธ