728x90
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부터 1까지 차례대로 연주한다면 descending, 둘 다 아니라면 mixed 이다. 연주한 순서가 주어졌을 때, 이것이 ascending인지, descending인지, 아니면 mixed인지 판별하는 프로그램을
www.acmicpc.net
a = list(map(int,input().split(' ')))
ascending = True
descending = True
for i in range(1,8):
if a[i] > a[i - 1]:
descending = False
elif a[i] < a[i - 1]:
ascending = False
if ascending:
print('ascending')
elif descending:
print('descending')
else:
print('mixed')
728x90
'Algorithm' 카테고리의 다른 글
(leetcode) Valid Palindrome (0) | 2021.01.04 |
---|---|
(백준) 10539번 : 수빈이와 수열 (0) | 2019.10.07 |
(백준) 15969 : 행복 (0) | 2019.10.07 |
(백준) 1874번 : 스택수열 (0) | 2019.09.20 |
(백준) 2798번 : 블랙잭 (0) | 2019.09.20 |
댓글