重量15倍数,邮费(15g,5元;30g,9元;45g,12元;60g,14元;75g~,15元)60以上里程每足1000m邮费+1元,75以上里程每足1000m邮费+2元
#include
main()
{
float weight,price;
int i,d,mileage;
price=0,weight=0,d=0;
printf("please input weight&mileage:");
scanf("%f%f",&weight,&mileage);
i=weight/15;
switch (i)
{
case 1:price=5; break;
case 2:price=9; break;
case 3:price=12; break;
case 4: {
d=mileage/1000;switch(d)
{
case 0: price=14;break;
case 1: price=14+d;break;
case 2: price=14+d;break;
case 3: price=14+d;break;
case 4: price=14+d;break;
case 5: price=14+d;break;
case 6: price=14+d;break;
case 7: price=14+d;break;
case 8: price=14+d;break;
case 9: price=14+d;break;
default: price=14+d;break;
}break;}
case 5:{
d=mileage/1000;switch(d){
case 0: price=15;break;
case 1: price=15+2*d;break;
case 2: price=15+2*d;break;
case 3: price=15+2*d;break;
case 4: price=15+2*d;break;
case 5: price=15+2*d;break;
case 6: price=15+2*d;break;
case 7: price=15+2*d;break;
case 8: price=15+2*d;break;
case 9: price=15+2*d;break;
default: price=15+2*d;break;
}break;}
}
printf("price=%f\n",price);
}