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 jjh at 2005-09-08 12:57:19 on Problem 2501
In Reply To:第一行可能没速度 Posted by:zdker at 2005-07-23 22:38:07
#include<stdio.h>
#include<string.h>
void main()
{
	int m[100][2],i=-1,l,t,j,k;
	char s[15],mm[100][15];
	double d;

	while(scanf("%s",s)!=EOF)
	{
		for(l=0;s[l]!='\0';l++);
		if(l==8&&s[2]==':')
		{
			i++;
			strcpy(mm[i],s);
			m[i][0]=((s[0]-'0')*10+s[1]-'0')*3600+((s[3]-'0')*10+s[4]-'0')*60+((s[6]-'0')*10+s[7]-'0');
			m[i][1]=-100;
		}
		else
		{
			m[i][1]=0;
			t=1;
			for(l=l-1;l>=0;l--)
			{
				m[i][1]+=(s[l]-'0')*t;
				t=t*10;
			}
		}
	}
	for(j=0;j<=i;j++)
	{
		if(m[j][1]==-100)
		{
			d=0.0;
			for(k=j-1;k>=0;k--)
			{
				if(m[k][1]!=-100)
				{
					d+=((m[j][0]-m[k][0])*m[k][1])/3600;
					m[j][0]=m[k][0];
				}
			}
			printf("%s %.2lf km\n",mm[j],d);

		}
	}
}


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