๐ป ๋ด ํ์ด
์ง๊ด์ ์ธ ํ์ด๋ผ๊ณ ์๊ฐํ์ง๋ง ์ ์๋ณด๋ค ์ฐํํด์ ํผ ๋๋์ด๋ผ ์ฝ๋๋ฅผ ๋ ์ฐพ์๋ดค๋ค.
t = input().split()
tmp = 0
s = sorted(t)
while True:
for i in range(1,len(t)):
if t[i-1] > t[i]:
tmp = t[i-1]
t[i-1] = t[i]
t[i] = tmp
print(*t)
if t == s:
break
๐ป ๋ค๋ฅธ ํ์ด
t = input().split()
for j in range(len(t)):
for i in range(1,len(t)):
if t[i-1] > t[i]:
t[i-1], t[i] = t[i], t[i-1]
print(*t)
๋ด ๊ธฐ์ต์ ์ด๊ฒ ๋ฒ๋ธ์ํธ๋ ๊ฐ์ฅ ๊ฐ๊น์ ๋ ๊ฒ๊ฐ๋ค.
์ถ์ฒ: https://it-garden.tistory.com/192
'PS > BOJ&Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค/3986] ์ข์ ๋จ์ด / ์คํ / ์คํ ํ์ฉ๋ฒ / ์คํ ์๋ฆฌ (0) | 2023.01.13 |
---|---|
[๋ฐฑ์ค/11179] 2์ง์ ๋ค์ง๊ธฐ (0) | 2023.01.12 |
[๋ฐฑ์ค/6996] ์ ๋๊ทธ๋จ.. ๋ฐ๋ก์ฐพ๊ธฐ (1) | 2023.01.10 |
[๋ฐฑ์ค/1159] ๋๊ตฌ๊ฒฝ๊ธฐ (4) | 2023.01.10 |
[๋ฐฑ์ค/5704] ํฌ๊ทธ๋จ/ ์นด์ดํธ, ๋์ ๋๋ฆฌ (1) | 2023.01.04 |