본문 바로가기

알고리즘/백준

음계

#include <iostream>
using namespace std;

int main(void)
{
	int a[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
	int b[8] = { 8, 7, 6, 5, 4, 3, 2, 1 };
	int c[8];
	int i = 0, j = 0;

	for (int i = 0; i < 8; i++)
		cin >> c[i];

	while (1)
	{
		if (c[i] == a[i]) //c, a 요소 비교
		{
			i++;
			if (i == 8)
			{
				cout << "ascending" << '\n';
				break;
			}
		}
		else if (c[j] == b[j]) //c, b 요소 비교
		{
			j++;
			if (j == 8)
			{
				cout << "descending" << '\n';
				break;
			}
		}
		else
		{
			cout << "mixed" << '\n';
			break;
		}
	}
	return 0;
}

 

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

나머지  (0) 2019.09.22
숫자의 개수  (0) 2019.09.21
최댓값  (0) 2019.09.16
최소, 최대  (0) 2019.09.15
더하기 사이클  (0) 2019.09.14