L1-047 装睡
你永远叫不醒一个装睡的人 —— 但是通过分析一个人的呼吸频率和脉搏,你可以发现谁在装睡!医生告诉我们,正常人睡眠时的呼吸频率是每分钟 15-20 次,脉搏是每分钟 50-70 次。下面给定一系列人的呼吸频率与脉搏,请你找出他们中间有可能在装睡的人,即至少一项指标不在正常范围内的人。
输入格式:
输入在第一行给出一个正整数N(≤10)。随后N行,每行给出一个人的名字(仅由英文字母组成的、长度不超过 3 个字符的串)、其呼吸频率和脉搏(均为不超过 100 的正整数)。
输出格式:
按照输入顺序检查每个人,如果其至少一项指标不在正常范围内,则输出其名字,每个名字占一行。
输入样例:
tex
4
Amy 15 70
Tom 14 60
Joe 18 50
Zoe 21 71
4
Amy 15 70
Tom 14 60
Joe 18 50
Zoe 21 71
输出样例:
tex
Tom
Zoe
Tom
Zoe
Solution:
java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
String[] input = in.readLine().split(" ");
int breathe = Integer.parseInt(input[1]);
int pulse = Integer.parseInt(input[2]);
if (breathe<15||breathe>20||pulse<50||pulse>70) sb.append(input[0]).append("\n");
}
System.out.print(sb);
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
String[] input = in.readLine().split(" ");
int breathe = Integer.parseInt(input[1]);
int pulse = Integer.parseInt(input[2]);
if (breathe<15||breathe>20||pulse<50||pulse>70) sb.append(input[0]).append("\n");
}
System.out.print(sb);
}
}