用switch语句编一程序,对于给定的一个百分制成绩,输出相应的五分制成绩,

2024-12-04 23:32:11
推荐回答(3个)
回答1:

楼上的橘基没有100分啊;还是c++程序,我给你个c的。
加了个输入非圆或谨法判断。楼主给分吧。。。
//--------------------------------------------------------
#include
int main()
{
unsigned char Score,Pscore;
printf("Please Input Scroe:\n");
scanf("%d",&Score);
if(Score>100||Score<0)
{
printf("The Score you entered is Illegal.");
return;
}
printf("The Score you entered is %d.\n",Score);
Pscore=Score/10;
switch(Pscore)
{
case 10:
case 9: printf("Your Score Grade is A.\n");break;
case 8: printf("Your Score Grade is B.\n");break;
case 7: printf("Your Score Grade is C.\n");break;
case 6: printf("Your Score Grade is D.\n");break;
default: printf("Your Score Grade is E.\n");break;
}
}
//----------------------------------------------------
楼主啊,有啥不懂的团仔可以问我哈。。。

回答2:

何必楼上那样如此复杂……弊枯

看我代码(C语言)

#include

void main()

{

 int score,grade,temp;

 printf("Input scroe:");

 scanf("%d",&score);

 if(score>100||score<0)

  printf("error\n");

 else

 {

  temp=score/10;

  switch(temp)

  {

   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';break;

  }

  printf("grade:%c\n",grade);

 }

 getch();

}

回答3:

#include悉判
void main()
{ int a,b;
cout<<"输入睁模改分数"< cin>>a;
b=a/10;
switch(b)
{case 9:cout<<"A"< case 8:cout<<"B"< case 7:cout<<"C"码段< case 6:cout<<"D"< default :cout<<"E"<
}
}

以上编译运行通过!!