C语言找错
发布网友
发布时间:2022-07-08 23:01
我来回答
共3个回答
热心网友
时间:2022-07-13 22:36
你根本就没有体现出来输入两次,对于两次的总结果进行判断!
#include <stdio.h>
main()
{
int score, mark=0,i;
for(i=0;i<2;i++)
{
printf("请输入第%d次的成绩:\n",i+1);
scanf("%d",&score);
if(score>=0&&score<=100)
mark+=score;
else
printf("此门成绩无效!");
}
mark = score / 10;
switch (mark)
{
case 20:
case 19:
case 18:
printf("%d--A\n",score);
break;
case 17:
case 16:
printf("%d--B\n",score);
break;
case 15:
case 14:
printf("%d--C\n",score);
break;
case 13:
case 12:
printf("%d--D\n",score);
break;
case 11:
case 10:
case 9:
case 8:
case 7:
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
printf("%D--E\n",score);
break;
default:
printf("Input error!\n");
}
}
热心网友
时间:2022-07-13 22:36
#include <stdio.h>
main()
{
int score, mark;
printf("please enter score:");
scanf("%d", &score);
mark = score / 10;
switch (mark)
{
case 20:
case 19:
case 18:
printf("%d--A\n",score);
break;
case 17:
case 16:
printf("%d--B\n",score);
break;
case 15:
case 14:
printf("%d--C\n",score);
break;
case 13:
case 12:
printf("%d--D\n",score);
break;
case 11:
case 10:
case 9:
case 8:
case 7:
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
printf("%d--E\n",score);//错误在这里,%d要小写。
break;
default:
printf("Input error!\n");
}
}其他好像没错了
热心网友
时间:2022-07-13 22:37
只是第2步的“若输入的成绩不是百分制成绩,则给出错误提示信息,并且不再进行下面的等级评价;若输入的成绩是百分制成绩,则计算总分,”没有写在程序里,加上验证这些和两门课的分相加就应该可以了吧