题目
运输公司对用户计算运费。
路程s越远,每公里运费越低。标准如下:
s<205km 没有折扣
250<=s<=500 2%折扣
500<=s<=1000 5%折扣
1000<=s<2000 8%折扣
2000<=s<3000 10%折扣
3000<=s 15%折扣
每公里每吨货物的基本运费为p,货物重量为w,距离为s,折扣为d,则总运费f的计算公式为:
f=p*w*s*(1-d)
以下为正确答案,但运行有问题!!!
#pragma warning(disable:4996)
#include <stdio.h>
void main()
{
int s, c;
float p, w, d, f;
printf("input p,w,s\n");
scanf("%f,%f,%d", &p, &w, &s);
if (s >=3000)
{
c = 12; //3000/250=12
}
else
{
c = s/250;
}
switch (c)
{