Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
同问。。 是不是公式的精度问题???In Reply To:谁能帮我看看代码,为什么G++编译是对的,而VC++是错的,有一个数据差了一秒钟 Posted by:Crying at 2006-07-12 01:19:14 > #include <stdio.h> > #include <string.h> > > int parse(char str[]) > { > int ans = ((str[0] - '0')*10 + (str[1] - '0'))*3600; > ans += ((str[3] - '0')*10 + (str[4] - '0')) * 60; > ans += (str[6] - '0')*10 + (str[7] - '0'); > return ans; > } > > int main() > { > char in[10]; > while(scanf("%s",in) != EOF&&in[0] != '-') > { > int t[6]; > t[1] = parse(in); > for(int i= 2;i <= 5;i ++) > { > scanf("%s",in); > t[i] = parse(in); > } > double tmp = (t[3] - t[1])*1.0/(t[4] - t[1])*(t[5] - t[2])*1.0/(t[3] - t[2]); > double tt = (t[5] - tmp*t[4])/(1-tmp); > int ttt = (int)(tt + 0.5); > printf("%.2d:%.2d:%.2d\n",(ttt/3600)%24,(ttt%3600)/60,ttt%60); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator