https://www.acmicpc.net/problem/6603
n = 0
choose = []
def combination(lst, index, level):
if level == 6:
print(*choose)
return
for i in range(index, n):
choose.append(lst[i])
combination(lst, i + 1, level + 1)
choose.pop()
while True:
t = list(map(int, input().split()))
if t[0] == 0:
break
n = t[0]
arr = t[1:]
combination(arr, 0, 0)
choose.clear()
print()
์๊ฐ
๋์ถฉ k๊ฐ์ ์ซ์ ์ค์์ 6๊ฐ๋ฅผ ๋ฝ์ผ๋ฉด ๋๋ ์กฐํฉ ๋ฌธ์
๊ตณ์ด ๋ฐ๋ณต๋ฌธ์ผ๋ก ํด๋น ๋ฌธ์ ๋ฅผ ํ์ด๋ณด์๋ฉด ์๋์ ๊ฐ์ด 6๋ฒ์ depth๋ฅผ ํ๊ฒ ๋๋ค.
for a in range(k + 1):
for b in range(a + 1, k + 1):
for c in range(b + 1, k + 1):
for d in range(c + 1, k + 1):
for e in range(d + 1, k + 1):
for f in range(e + 1, k + 1):
์ฌ๋งํ ์กฐํฉ ๋ฌธ์ ๋ ์ฌ๊ท ํจ์๋ก ํ๋ฉด ๊ฐ๋จํด์ง๋ค.