double a;
scanf("%lf",&a);
if (a >= 90&&a<=100)
printf("A");
else if (a >= 80&&a<=89)
printf("B");
else if (a >= 70 && a <= 79)
printf("C");
else if (a >= 60 && a <= 69)
printf("D");
else if (a >= 0 && a <= 59)
printf("E");
else
printf("输入错误");
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
float score;
int n;
puts("请输入分数");
scanf("%f", &score);
if (score >= 0.0f && score <= 100.0f) {
n = score / 10;//技巧点
switch (n) {
case 10:
case 9:printf("%f is A\n", score); break;
case 8:printf("%f is B\n", score); break;
case 7:printf("%f is C\n", score); break;
case 6:printf("%f is D\n", score); break;
default:printf("%f is D\n", score);
}
}
else {
puts("ERROR,请输入分数[0,100]");
}
return 0;
}
登录后提交答案