输入百分制成绩,要求输出成绩的等级A(100~90),B(89~80),C(79~70),D(69~60),E(59~0)

#include int main() { float score; char grade; printf("请输入学生成绩:/n"); scanf("%f",&score); while(score>100||score<0) {printf("/n输入信息有误,请重输"); scanf("%f",&score); } switch((int)(score/10)) { case 10: case 9:grade='A';break; case 8:grade='B';break; case 7:grade='C';break; case 6:grade='D';break; case 5: case 4: case 3: case 2: case 1: case 0:grade='E';break; } printf("成绩是:%5.1f,相应的等级:%c。/n",score,grade); system("pause"); }

你可能感兴趣的:(输入百分制成绩,要求输出成绩的等级A(100~90),B(89~80),C(79~70),D(69~60),E(59~0))