白俊6764 Sounds fishy!
5202 ワード
質問する
A fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:
Your task is to read a sequence of depth readings and determine if the alarm will sound.
入力
The input will be four positive integers, representing the depth readings. Each integer will be on its own line of input.
しゅつりょく
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 be Fish At Constant Depth. Otherwise, the output should be No Fish.
入力例1
1
10
12
13
サンプル出力1
Fish Rising
解法
値が連続的に小さくなるか、大きくなるか、すべて同じかを理解します.
コード#コード#
depth = []
for _ in range(4):
depth.append(int(input()))
result = ''
if depth[0] < depth[1] < depth[2] < depth[3]:
result = 'Fish Rising'
elif depth[0] > depth[1] > depth[2] > depth[3]:
result = 'Fish Diving'
elif depth[0] == depth[1] == depth[2] == depth[3]:
result = 'Fish At Constant Depth'
else:
result = 'No Fish'
print(result)
白俊6764 Sounds fishy!
Reference
この問題について(白俊6764 Sounds fishy!), 我々は、より多くの情報をここで見つけました
https://velog.io/@mynote/백준-6764-Sounds-fishy
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
depth = []
for _ in range(4):
depth.append(int(input()))
result = ''
if depth[0] < depth[1] < depth[2] < depth[3]:
result = 'Fish Rising'
elif depth[0] > depth[1] > depth[2] > depth[3]:
result = 'Fish Diving'
elif depth[0] == depth[1] == depth[2] == depth[3]:
result = 'Fish At Constant Depth'
else:
result = 'No Fish'
print(result)
Reference
この問題について(白俊6764 Sounds fishy!), 我々は、より多くの情報をここで見つけました https://velog.io/@mynote/백준-6764-Sounds-fishyテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol