其实不难……照着书上的例子改就OK了,以下是程序
#include "stdio.h"
#include "conio.h"
main()
{int x;
printf("Qing shu ru cheng ji:",x);
scanf("%d",&x);
if(x>100||x<0)
printf("Mei you na yang de cheng ji!Cheng ji wei %d cuo wu!",x);
else
{switch(x/10)
{case 9: printf("Cheng ji wei %d,You xiu!",x);break;
case 8:printf("Cheng ji wei %d,Liang hao!",x);break;
case 6:printf("Cheng ji wei %d,Ji ge!",x);
default:printf("Cheng ji wei %d,I am sorry to talk about grade to you~",x);
}
}
getch();
}
以下的是if-else,上面是switch
#include "stdio.h"
#include "conio.h"
main()
{int x;
printf("Qing shu ru cheng ji:",x);
scanf("%d",&x);
if(x>100||x<0)
printf("Mei you na yang de cheng ji!Cheng ji wei %d cuo wu!",x);
else
{
if(x>=90)
printf("Cheng ji wei %d,you xiu!",x);
else
if(x>=80)
printf("Cheng ji wei %d,liang hao!",x);
else
if(x>=60)
printf("Cheng ji wei %d,ji ge!",x);
else
printf("Cheng ji wei %d,I am sorry to talk about grade to you~",x);
}
getch();
}
希望你不要产生依赖性…………程序仅供参考,希望你能做出自己的程序