python-algorithm
[백준] 17293
무적김두칠
2021. 2. 5. 15:38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
n=int(input())
first=n
while n!=0:
if n>1:
if n-1>1:
print("%d bottles of beer on the wall, %d bottles of beer."%(n,n))
print("Take one down and pass it around, %d bottles of beer on the wall."%(n-1))
else:
print("%d bottles of beer on the wall, %d bottles of beer." % (n, n))
print("Take one down and pass it around, 1 bottle of beer on the wall.")
elif n==1:
print("%d bottle of beer on the wall, %d bottle of beer." % (n, n))
print("Take one down and pass it around, no more bottles of beer on the wall.")
print()
n-=1
if n==0:
if first !=1:
print("No more bottles of beer on the wall, no more bottles of beer.")
print("Go to the store and buy some more, %d bottles of beer on the wall."%first)
else:
print("No more bottles of beer on the wall, no more bottles of beer.")
print("Go to the store and buy some more, %d bottle of beer on the wall." % first)
|
cs |
이 문제는 크게 어렵진 않은데 맥주가 1병일때 아예없을때만 예외처리해서 해주면 됩니다
반응형