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

牛兄牛弟们,错哪了?

Posted by Pzjay at 2009-07-02 11:31:59 on Problem 2501
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
	int len,speed=0,h2,m2,s2,h1,m1,s1;
	char pzj[50];
	double t,ldis,dis=0; //忘初始化	了
	char sor[50]={0};
	while(gets(pzj)!=NULL)
	{
		len=strlen(pzj);
		if(len>=10)
		{
			h2=(sor[0]-'0')*10+sor[1]-'0';
		    m2=(sor[3]-'0')*10+sor[4]-'0';
		    s2=(sor[6]-'0')*10+sor[7]-'0';
			h1=(pzj[0]-'0')*10+pzj[1]-'0';
		    m1=(pzj[3]-'0')*10+pzj[4]-'0';
		    s1=(pzj[6]-'0')*10+pzj[7]-'0';
			t=(h1-h2)+(m1-m2)/60.0+(s1-s2)/3600.0;
			dis=t*speed;
			strcpy(sor,pzj);
			h2=(sor[0]-'0')*10+sor[1]-'0';
		    m2=(sor[3]-'0')*10+sor[4]-'0';
		    s2=(sor[6]-'0')*10+sor[7]-'0';
			speed=atoi(sor+9);
			ldis=dis;
		}
		else
		{
			dis=0;
			h1=(pzj[0]-'0')*10+pzj[1]-'0';
		    m1=(pzj[3]-'0')*10+pzj[4]-'0';
		    s1=(pzj[6]-'0')*10+pzj[7]-'0';
			t=(h1-h2)+(m1-m2)/60.0+(s1-s2)/3600.0;	
			dis=t*speed;
                        if(strcmp(pzj,"00:00:01")==0)
					printf("%s 0.00 km\n",pzj);
			else
			printf("%s %.2f km\n",pzj,dis+ldis);
		}
	}
	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