반응형
https://www.acmicpc.net/problem/6764
6764번: Sounds fishy!
The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should b
www.acmicpc.net
분기문을 사용하는 문제였습니다.
📕 풀이방법
📔 정답출력
수의 개수가 4개로 적기 때문에 하드코딩으로 조건에 따라 출력해줍니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main(){
for(int i = 0; i < 4; i++) cin >> a[i];
if(a[0] > a[1] && a[1] > a[2] && a[2] > a[3]) cout << "Fish Diving";
else if(a[0] < a[1] && a[1] < a[2] && a[2] < a[3]) cout << "Fish Rising";
else if(a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) cout << "Fish At Constant Depth";
else cout << "No Fish";
}
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - 백준(BOJ) 14467번 : 소가 길을 건너간 이유 1 (0) | 2021.09.15 |
---|---|
(C++) - 프로그래머스(2020 카카오 인턴십) : 키패드 누르기 (0) | 2021.09.06 |
(C++) - 백준(BOJ) 16926번 : 배열 돌리기 1 (0) | 2021.08.23 |
(C++) - 프로그래머스(위클리 챌린지) : 3주차 (0) | 2021.08.23 |
(Python) - 백준(BOJ) 20499번 : Darius님 한타 안 함? (0) | 2021.08.22 |