오타가 있는 문제입니다.
네 수가 모두 같을 때는 "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;
}
'PS > 백준' 카테고리의 다른 글
[C++] 백준 2468번: 안전 영역 (0) | 2021.09.12 |
---|---|
[C++] 백준 20046번: Road Reconstruction (0) | 2021.09.09 |
[C++] 백준 10799번: 쇠막대기 (0) | 2021.02.04 |
[C++] 백준 16206번: 롤케이크 (0) | 2021.01.23 |
[C++] 백준 2110번: 공유기 설치 (0) | 2020.12.30 |
댓글