我用的是VC++6.0通过 新建-工程-Win23 Console Application。 新建-文件-C++ Sourse File输入了程序:
#include<stdio.h>main(){intc,s;floatp,w,d,f;scanf("%f%f%d",&p,&w,&s);c=s/250;switch(c...
#include<stdio.h>
main()
{
int c,s;
float p,w,d,f;
scanf("%f%f%d",&p,&w,&s);
c=s/250;
switch(c )
{
case 0: d=0;break;
case 1: d=2;break;
case 2:
case 3: d=5;break;
case 4:
case 5:
case 6:
case 7: d=8;break;
case 8:
case 9:
case 10:
case 11:d=10;break;
default: d=15;
}
f=p*w*s(1-d/100.0);
printf("freight=%15.4f",f);
} 展开
main()
{
int c,s;
float p,w,d,f;
scanf("%f%f%d",&p,&w,&s);
c=s/250;
switch(c )
{
case 0: d=0;break;
case 1: d=2;break;
case 2:
case 3: d=5;break;
case 4:
case 5:
case 6:
case 7: d=8;break;
case 8:
case 9:
case 10:
case 11:d=10;break;
default: d=15;
}
f=p*w*s(1-d/100.0);
printf("freight=%15.4f",f);
} 展开
2个回答
展开全部
scanf输入的三个数要有一个分隔符,否则不知道输入了几个数。还有几个小问题,改后参考如下:
#include<stdio.h>
void main()
{
int c(0), s(0);
float p(0), w(0), d(0), f(0);
scanf_s("%f %f %d", &p, &w, &s);
c = s / 250;
switch (c)
{
case 0: d = 0; break;
case 1: d = 2; break;
case 2:
case 3: d = 5; break;
case 4:
case 5:
case 6:
case 7: d = 8; break;
case 8:
case 9:
case 10:
case 11:d = 10; break;
default: d = 15;
}
f = p*w*s*(1 - d / 100.0);
printf("freight=%15.4f", f);
}
2014-03-07
展开全部
来赚经验,你倒数第二行少了个“*”,
f=p*w*s*(1-d/100.0);
f=p*w*s*(1-d/100.0);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询