https://www.acmicpc.net/problem/2920
2920번: 음계
다장조는 c d e f g a b C, 총 8개 음으로 이루어져있다. 이 문제에서 8개 음은 다음과 같이 숫자로 바꾸어 표현한다. c는 1로, d는 2로, ..., C를 8로 바꾼다. 1부터 8까지 차례대로 연주한다면 ascending, 8
www.acmicpc.net
Python
flag 변수를 2개 사용하기(ascending, descending)
numbers = list(map(int, input().split(" ")))
ascending = True
descending = True
for i in range(0, 7):
if numbers[i] > numbers[i + 1]:
ascending = False
if numbers[i + 1] > numbers[i]:
descending = False
if ascending:
print('ascending')
elif descending:
print('descending')
else:
print('mixed')
'알고리즘 > 백준' 카테고리의 다른 글
[Python] 백준 2798번 - 블랙잭 (0) | 2021.07.21 |
---|---|
[Python] 백준 5397번 - 키로거 (0) | 2021.07.21 |
[Python] 백준 10996번 - 별 찍기 - 21 (0) | 2020.06.11 |
[Python] 백준 2446번 - 별 찍기 - 9 (0) | 2020.06.09 |
[Python] 백준 2523번 - 별 찍기 - 13 (0) | 2020.06.09 |
댓글