백준 2920 - 음계

황재진·2024년 3월 7일

백준

목록 보기
16/54
post-thumbnail

for문을 이용해 체크하면 쉽게 해결할 수 있는 문제입니다.

#include <iostream>

int main()
{
	int n[8];

	for (int i = 0; i < 8; i++)
		std::cin >> n[i];

	bool is_Ascending = true;
	bool is_Descending = true;
	for (int i = 0; i < 8; i++)
	{
		if (n[i] != i + 1)
			is_Ascending = false;
		if (8 - n[i] != i)
			is_Descending = false;
	}

	if (is_Ascending)
		std::cout << "ascending";
	else if (is_Descending)
		std::cout << "descending";
	else
		std::cout << "mixed";

	return 0;
}
profile
프로그래밍, 쉐이더 등 이것저것 다해보는 게임 개발자입니다

0개의 댓글