绝对原创,望采纳:
#include?<stdio.h>#include?<stdlib.h>
int?main()
{
float?weight,pay,m,a,b,h;
int?s;
????printf("请输入包裹的长宽高:");
scanf("%f%f%f",&a,&b,&h);
if?(a>1||b>1||h>1)
{
printf("包裹长宽高不符合要求,不予邮寄\n");
return?0;
}
printf("请输入包裹重量:");
scanf("%f",&weight);
if?(weight>30)
{
printf("重量超过30kg,不予邮寄\n");
return?0;
}
s=(int)(weight-0.001)/10;//假定每个包裹重量超过1克
switch?(s)
{
???case?0:
???m=1.0f;
???break;
???case?1:
???m=0.9f;?
???break;
???case?2:
???m=0.8f;
???break;
???default:
???printf("重量输入错误,不予邮寄\n");
???return?0;
}
????
pay?=?weight*m+0.5f;
printf("邮资为:%.2f\n",pay);
system("pause");
}