| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 429 人关注过本帖
标题:[求助]大家看我编的对吗?
取消只看楼主 加入收藏
qzgd
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-7-15
收藏
 问题点数:0 回复次数:1 
[求助]大家看我编的对吗?

main()
{
float allsecond;
int type;
int run_hour,run_second,run_day,run_month,run_year,run_minute;
int end_year,end_month,end_day,end_hour,end_minute,end_second;
float sum,near,far,IP,sa,sb;

printf("input start time:\n");
printf("start year:");
scanf("%d",&run_year);
printf("start month:");
scanf("%d",&run_month);
printf("start day:");
scanf("%d",&run_day);
printf("start hour:");
scanf("%d",&run_hour);
printf("start minute:");
scanf("%d",&run_minute);
printf("start second:");
scanf("%d",&run_second);
printf("input end time:\n");
printf("end year:");
scanf("%d",&end_year);
printf("end month:");
scanf("%d",&end_month);
printf("end day:");
scanf("%d",&end_day);
printf("end hour:");
scanf("%d",&run_hour);
printf("end minute:");
scanf("%d",&end_minute);
printf("end second:");
scanf("%d",&end_second);

allsecond=

(run_year*31536000+run_month*2678400+run_day*86400+run_hour*3600+run_minute*60+run_second)-

(end_year*31536000+end_month*2678400+end_day*86400+end_hour*3600+end_minute*60+end_second);

if(run_hour<=7&&run_hour>0)
{
if(allsecond<=180) sa=0.22*allsecond/60;
else if(allsecond>180) sb=0.22*3+0.11*(allsecond-180)/60;
near=(sa+sb)/2;
far=(0.07*allsecond/6)/2;
IP=(0.03*allsecond/6+near)/2; }
else if(run_hour>7&&run-hour<=24)
{near=sa+sb;
far=0.07*allsecond/6;
IP=0.03*allsecond/6+near;}


printf("input tel type(1 2 3 4):");
scanf("%d",&type);
switch(type)
{case 1:sum=near;break;
case 2:sum=far;break;
case 3:sum=IP;break;
case 4:sum=far+IP;break;}
printf("cost is %f",sum);

}

[此贴子已经被作者于2007-7-16 3:27:26编辑过]

2007-07-16 03:15
qzgd
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-7-15
收藏
得分:0 

为什么float far 后面的都不对了,5555555555555555

2007-07-16 03:15
快速回复:[求助]大家看我编的对吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020278 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved