请高手 帮忙做一道c语言题 编程,把百分制成绩转换成5级记分制,要求用switch语句。 90分以上(包括90):

2024-11-24 04:42:17
推荐回答(5个)
回答1:

#include "stdio.h"
#include "stdlib.h"

int main()
{
int score,level;
char band;
printf("Input Score:");
scanf("%d",&score);
level=score/10;
switch(level)
{
case 10:
case 9: band='A'; break;
case 8: band='B'; break;
case 7: band='C'; break;
case 6: band='D'; break;
default: band='E'; break;
}
printf("%d的等级为%c\n",score,band);
system("pause");
return 0;
}

回答2:

#include
main()
{
int s,y;
y=(int)(s/10);
printf("Input Score:");
scanf(“%d”.&s);
switch(y)
{
case 9:case 10: printf("%d的等级为A",s);break;
case 8: printf("%d的等级为B",s);break;
case 7: printf("%d的等级为C",s);break;
case 6: printf("%d的等级为D",s);break;
default: printf("%d的等级为E",s);
}
}

回答3:

#include "iostream.h"
#include "stdio.h"
void main()
{
int a;
cin>>a;

int b=a/10;
switch (b)
{
case 10:
cout<<"A"< case 9:
cout<<"A"< case 8:
cout<<"B"< case 7:
cout<<"C"< case 6:
cout<<"D"< default:
cout<<"E"< }
}

回答4:

在switch前面加个b=成绩%10
然后switch(b)

回答5:

这样的话输入108也会输出A而不是输出错误