본문 바로가기
  • Let's study
PS/Baekjoon

[C++] 백준 6764번: Sounds fishy!

by 코딩고수이고파 2021. 3. 13.

오타가 있는 문제입니다.

네 수가 모두 같을 때는 "Fish at Constant Depth"라고 출력해야 하고

적혀진 세 조건을 만족하지 못했을 때는 "No Fish"라고 출력해야 합니다.(No Fish에 . 을 빼야함)

#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int arr[4];
	int up = 0;
	int down = 0;
	int same = 0;

	for (int i = 0; i < 4; i++) {
		cin >> arr[i];
	}
	for (int i = 1; i < 4; i++) {
		if (arr[i] > arr[i - 1])
			up++;
		else if (arr[i] < arr[i - 1])
			down++;
		else
			same++;
	}
	if (up == 3)
		cout << "Fish Rising";
	else if (down == 3)
		cout << "Fish Diving";
	else if (same == 3)
		cout << "Fish At Constant Depth";
	else
		cout << "No Fish";

	return 0;
}

댓글