|
发表于 2013-4-28 01:25:35
|
显示全部楼层
#include<stdio.h> // 根据路程S求总运费F,C为折扣。
int main()
{
long double f,c,s;
int p=2;//设每吨二元.
int w=258;//设物重258吨.
scanf ("%lf",&s);
if(s<250)
{
f=p*w*s;printf("%lf\n",f);
}
else if (s>=250 && s<500)
{
c=1.0-0.02;
f=p*w*s*c;
printf("总运费为:%lf\n",f);
}
else if (s>=500 && s<1000)
{
c=1.0-0.05;
f=p*w*s*c;
printf("总运费为:%lf\n",f);
}
else if (s>=1000 && s<2000)
{
c=1.0-0.08;
f=p*w*s*c;
printf("总运费为:%lf\n",f);
}
else if (s>=2000 &&s<3000)
{ c=1.0-0.1;
f=p*w*s*c;
printf("总运费为:%lf\n",f);
}
else if (s>=3000)
{c=1.0-0.15;
f=p*w*s*c;
printf("总运费为:%lf\n",f);
}
return 0;
}
|
|