健康预警
分数 10
全屏浏览题目
切换布局
作者 陈越
单位 浙江大学
本题请你实现一个健康预警小功能,按照下列表格中的规则,对每个用户给出其健康预警颜色。表格上方横栏中的数字区间表示年龄段,下面格子中的数字区间是对应年龄段的健康指数区间,最右边一列给出对应年龄段、健康指数区间应该输出的预警颜色。
[1, 60) | [60, 80) | [80,200] | 预警颜色 |
---|---|---|---|
[0,30) | [0, 50) | [0, 60) | 红色(Red) |
[30, 60) | [50, 70) | [60, 75) | 黄色(Yellow) |
[60, 100] | [70, 100] | [75, 100] | 绿色(Green) |
输入格式:
输入在一行中给出一位用户的年龄和健康指数,其中年龄在 [1, 200] 区间内,健康指数在 [0, 100] 区间内。
输出格式:
按以下格式输出:
Age: 输入年龄
Healthy Index: 输入健康指数
预警信息
其中 预警信息
分为 4 种:
- 红色预警显示为
Red Alert!!
- 黄色预警显示为
Yellow Alert!
- 绿色显示为
Green ^_^
输入样例 1:
70 49
输出样例 1:
Age: 70
Healthy Index: 49
Red Alert!!
输入样例 2:
23 50
输出样例 2:
Age: 23
Healthy Index: 50
Yellow Alert!
输入样例 3:
80 80
输出样例 3:
Age: 80
Healthy Index: 80
Green ^_^
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
#include <stdio.h>
int main(){
int age,h;
scanf("%d %d",&age,&h);
if(age>=1&&age<60&&h>=0&&h<30){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Red Alert!!\n");
}
else if(age>=60&&age<80&&h>=0&&h<50){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Red Alert!!\n");
}
else if(age>=80&&age<=200&&h>=0&&h<60){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Red Alert!!\n");
}
else if(h>=30&&h<60&&age>=1&&age<60){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Yellow Alert!\n");
}
else if(h>=50&&h<70&&age>=60&&age<80){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Yellow Alert!\n");
}
else if(h>=60&&h<75&&age>=80&&age<=200){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Yellow Alert!\n");
}
else if(h>=60&&h<=100&&age>=1&&age<60){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Green ^_^\n");
}
else if(h>=70&&h<=100&&age>=60&&age<80){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Green ^_^\n");
}
else if(h>=75&&h<=100&&age>=80&&age<=200){
printf("Age: %d\n",age);
printf("Healthy Index: %d\n",h);
printf("Green ^_^\n");
}
return 0;
}