请高手 帮忙做一道c语言题 编程,把百分制成绩转换成5级记分制,要求用switch语句。 90分以上(包括90):
发布网友
发布时间:2022-04-26 17:06
我来回答
共5个回答
热心网友
时间:2023-10-16 03:46
#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;
}
热心网友
时间:2023-10-16 03:47
#include<stdio.h>
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);
}
}
热心网友
时间:2023-10-16 03:47
#include "iostream.h"
#include "stdio.h"
void main()
{
int a;
cin>>a;
int b=a/10;
switch (b)
{
case 10:
cout<<"A"<<endl;
case 9:
cout<<"A"<<endl;
case 8:
cout<<"B"<<endl;
case 7:
cout<<"C"<<endl;
case 6:
cout<<"D"<<endl;
default:
cout<<"E"<<endl;
}
}
热心网友
时间:2023-10-16 03:48
在switch前面加个b=成绩%10
然后switch(b)
热心网友
时间:2023-10-16 03:48
这样的话输入108也会输出A而不是输出错误