习题5.6参考答案,switch的练习

/*
Name: xt5_6.c
Author:yaoguo
Date: 17-11-05 10:37
Description: 习题5.6参考答案,switch的练习
此解答的缺陷在于未对输入数据进行判断
请大家将之完善
*/
【习题5.6参考答案,switch的练习】main()
{
float score; /* 分数 */
intgrd; /* 存放 score/10 的值 */
chargrade;

printf("请输入成绩:");
scanf("%f", &score);
grd = (int)(score/10);
switch(grd)
{
case 10:
case 9 :grade = 'A'; break;
case 8 :grade = 'B'; break;
case 7 :grade = 'C'; break;
case 6 :grade = 'D'; break;
default:grade = 'E';
}
printf("其等级为 %c", grade);


getch();
}



    推荐阅读