中易网

C语言的问题,求答案感谢

答案:3  悬赏:80  
解决时间 2021-01-17 12:14
  • 提问者网友:咪咪
  • 2021-01-16 18:18
C语言的问题,求答案感谢
最佳答案
  • 二级知识专家网友:青灯有味
  • 2021-01-16 19:14
#include
int main()
{
float score;//score为分数
char grade;//grade为等级
printf("请输入学生成绩:");
scanf("%f",&score);
if(score>=90 && score<=100)
grade='A';
else if(score>=80 && score<90)
grade='B';
else if(score>=70 && score<80)
grade='C';
else if(score>=60 && score<70)
grade='D';
else if(score>=0 && score<60)
grade='E';
else
printf("输入数据错误!\n");
printf("score=%.1f\tgrade=%c\n",score,grade);
return 0;
}
这么简单的题自己想!不好好学习
全部回答
  • 1楼网友:轮獄道
  • 2021-01-16 20:35
第一空:&score;第二空:score>90&&score<100;第三空:score>60&&score<70;第四空:score>0&&score<60;第五空:score<0||score>100
  • 2楼网友:上分大魔王
  • 2021-01-16 19:56
/////////////if
#include
int main()
{
float score;
char grade;、
scanf("%f",&score);
if(score>=90 && score<=100)
grade='A';
else if(score>=80 && score<90)
grade='B';
else if(score>=70 && score<80)
grade='C';
else if(score>=60 && score<70)
grade='D';
else if(score>=0 && score<60)
grade='E';
else
printf("输入数据错误!\n");
return 0;
}
////////////////////switch
#include
int main()
{
float score;
char grade;
printf("请输入学生成绩:");
scanf("%f",&score);
int a = (int)score%10;
switch(a) {
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;
default:printf("输入数据错误!\n");break;
}
return 0;
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息