#include<stdio.h>
int main()
{
int score,s1;
char grade;
printf("Please input score:\n");
s1=scanf("%d", &score);
if (score < 0 || score > 100||s1==0)
printf("Input error!\n");
else
{
if (score >= 90)
grade = 'A';
else if (score >= 80)
grade = 'B';
else if (score >= 70)
grade = 'C';
else if (score >= 60)
grade = 'D';
else grade = 'E';
printf("grade: %c\n", grade);
}
return 0;
}
学习心得:这是一个对学生考试成绩五分制打分的题目;1.s1=scanf("%d", &score);和if (score < 0 || score > 100||s1==0)是对输入的数据的判断真否2.else{if,else if,else if}是对printf语句的情况保函3.\n这个换行符若不写则对题目答案的检验由影响。