티스토리 뷰

PS/백준

2920번 음계

unside 2019. 6. 22. 17:12

백준 2920번

문제 사이트 :
https://www.acmicpc.net/problem/2920

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

#define Max 8

int Array[Max];
int Array_1[Max];

int main(void) {
	for (int i = 0; i < Max; i++) {
		scanf("%d", &Array[i]);
	}
	for (int i = 0; i < Max - 1; i++) {
		Array_1[i] = Array[i] - Array[i + 1];
	}
	bool check = true;
	for (int i = 0; i < Max - 2; i++) {
		if (Array_1[i] != Array_1[i + 1]) {
			check = false;
			break;
		}
	}
	if (check) {
		if (Array_1[0] == 1) {
			printf("descending");
		}
		else{
			printf("ascending");
		}
	}
	else {
		printf("mixed");
	}
	return 0;
}

'PS > 백준' 카테고리의 다른 글

4344번 평균은 넘겠지  (0) 2019.06.22
2941번 크로아티아 알파벳  (0) 2019.06.22
2908번 상수  (0) 2019.06.22
2675번 문자열 반복  (0) 2019.06.22
2577번 숫자의 개수  (0) 2019.06.22
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함