用if-else语句编程,根据输入的百分制成绩score,转换成相应的五分制成绩grade后输出,已知转换标准
1 #include<stdio.h> 2 int main() 3 { 4 int score; 5 char grade; 6 printf("请输入百分制成绩:"); 7 scanf("%d",&score); 8 if(score>=0&&score<60) 9 { 10 grade='E'; 11 printf("五分制成绩为%c\n",grade); 12 } 13 else if(score>=60&&score<70) 14 { 15 grade='D'; 16 printf("五分制成绩为%c\n",grade); 17 } 18 else if(score>=70&&score<80) 19 { 20 grade='C'; 21 printf("五分制成绩为%c\n",grade); 22 } 23 else if(score>=80&&score<90) 24 { 25 grade='B'; 26 printf("五分制成绩为%c\n",grade); 27 } 28 else if(score>=90&&score<=100) 29 { 30 grade='A'; 31 printf("五分制成绩为%c\n",grade); 32 } 33 else 34 printf("输入成绩有误,请重新输入!"); 35 return 0; 36 }