这个程序怎么不管输入啥都是显示0.0000
有懂得的大神麻烦不惜赐教下:big#include <stdio.h>
void main()
{
int c,s;
float p,w,d,f;
scanf("%f,%f,%d",&p,&w,&s);
if(s>=3000)
{
c=12;
}
else
{
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;
case 12:
d=15;
break;
}
f = p*w*s*(1-d/100.0);
printf("freight=%15.4f\n",f);
system("pause");
}
我复制你的代码运行的结果是
scanf("%f,%f,%d",&p,&w,&s);改为
scanf("%f%f%d",&p,&w,&s); 牡丹花下死做鬼 发表于 2015-6-21 19:36
我复制你的代码运行的结果是
谢谢:big 仰望天上的光 发表于 2015-6-21 19:56
scanf("%f,%f,%d",&p,&w,&s);改为
scanf("%f%f%d",&p,&w,&s);
谢谢大神:lol:
页:
[1]