#include <stdio.h>
int main()
{
int data;
printf("请输入成绩:\n");
scanf("%d",&data);
switch(data/10){
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
printf("等级为D,不合格,学渣\n");
break;
case 6:
case 7:
printf("等级为C,合格,混日子\n");
break;
case 8:
case 9:
printf("等级为B,优秀\n");
break;
case 10:
printf("等级为A,不是正常人\n");
break;
default:
printf("成绩非法,请重新输入\n");
}
return 0;
}
2.某公司的运费问题,路程越远,折扣越大
#include<stdio.h>
int main()
{
float discount;
int distance;
printf("请输入路程\n");
scanf("%d",&distance);
if(distance<250){
discount=0;
}
else if(distance>=250 && distance<500){
discount=2;
}
else if(distance>=500 && distance<1000){
discount=5;
}
else if(distance>=1000 && distance<2000){
discount=8;
}
else if(distance>=2000 && distance<3000){
discount=10;
}
else{
discount=15;
}
printf("折扣为:%.2f",(float)discount/100);
return 0;
}