Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谁能帮我看看代码,为什么G++编译是对的,而VC++是错的,有一个数据差了一秒钟

Posted by Crying at 2006-07-12 01:19:14 on Problem 2854
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator