----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------
#include<stdio.h>
void main()
{
float x;
printf("Input a score:");
scanf("%f",&x);
if(x>=90)
printf("A\n");
else if(x>=80)
printf("B\n");
else if(x>=70)
printf("C\n");
else if(x>=60)
printf("D\n");
else
printf("E\n");
}
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------
用switch函数更方便
----------------解决方案--------------------------------------------------------
我觉的题目倒过来倒是可以用switch函数...
----------------解决方案--------------------------------------------------------
楼上既然提到了switch()函数,就用它来实现一下.
#include <stdio.h>
#include <conio.h>
int main(void)
{
int score;
clrscr();
scanf("%d",&score);
switch((int)(score/10))
{
case 0: case 1: case 2: case 3: case 4:
case 5: printf("E\n");break;
case 6: printf("D\n");break;
case 7: printf("C\n");break;
case 8: printf("B\n");break;
case 9:
case 10:printf("A\n");break;
}
getch();
}
----------------解决方案--------------------------------------------------------
还是楼上的好,写出来了,我只说说没写。。。
----------------解决方案--------------------------------------------------------
老潭的C语言中有这原本题目
----------------解决方案--------------------------------------------------------