鱼C论坛

 找回密码
 立即注册
查看: 4087|回复: 4

关于C的问题。。求指点。。

[复制链接]
发表于 2013-3-28 00:25:42 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
QQ截图20130328002344.png #include<stdio.h>
void main()
{
double p,w,s,d,f;
printf("分别输入货物的\n基本运费\n货物重量\n运输路程\n");
scanf("%lf,%lf,%lf\n",&p,&w,&s);
switch(s>0 && s<250)
{case 1:
{
  f=p*w*s*(1-0);
  printf("总运费为%lf\n",f);
}
  case 0:switch(s>=250 && s<500)
     {case 1:
     {
    f=p*w*s*(1-0.02);
    printf("总运费为%lf\n",f);break;
     }
  case 0:switch(s>=500 && s<1000)
      {case 1:
      {
       f=p*w*s*(1-0.05);
             printf("总运费为%lf\n",f);break;
      }
  case 0:switch(s>=1000 && s<2000)
      {case 1:
      {
       f=p*w*s*(1-0.08);
             printf("总运费为%lf\n",f);break;
      }
  case 0:switch(s>=2000 && s<3000)
      {case 1:
      {
       f=p*w*s*(1-0.1);
             printf("总运费为%lf\n",f);break;
      }
  case 0:switch(s>3000 || s==3000)
      {case 1:
      {
       f=p*w*s*(1-0.15);
             printf("总运费为%lf\n",f);break;
      }
      }
      }
      }
      }
      }
}
}

最后执行的时候我输入三个数,按回车没反应。。但在输入一个其他的字符时候。回车 答案就出来了
而且答案还是对的。。
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2013-3-28 08:34:33 | 显示全部楼层
  1. scanf("%lf,%lf,%lf\n",&p,&w,&s);
复制代码
scanf语句不要加" \n "符即
  1. scanf("%lf,%lf,%lf",&p,&w,&s);
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2013-3-28 10:39:10 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2013-3-28 11:03:40 | 显示全部楼层
其中的原理我也不太清楚,现在也先学习。嘿嘿!给你个链接。自己去看咯。
http://www.360doc.com/content/10/1009/11/3079882_59545977.shtml
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2013-3-29 12:58:11 | 显示全部楼层
小亮1201 发表于 2013-3-28 11:03
其中的原理我也不太清楚,现在也先学习。嘿嘿!给你个链接。自己去看咯。
http://www.360doc.com/content/ ...

谢谢啦!!!~~~~~~~~~
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-8-5 03:26

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表