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

why WA?

Posted by 00448322 at 2007-10-11 20:08:39 on Problem 2501
不知道哪里错了  有人能看看吗?

#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <iomanip.h>

void main()
{
	
	int count;
	char* val;
	int hour=0,minute=0,second=0;
	int lh,lm,ls;
	float speed=0,cs=0;
	bool compute=false;
	float mile=0;
	while(!cin.eof())
	{
		char temp[1000];
		cs=speed;
		compute=true;
		count=1;
		lh=hour;
		lm=minute;
		ls=second;
		cin.getline(temp,1000,'\n');
//		cout<<temp<<endl;
		char sep[5]=" :";
		val=strtok(temp,sep);
		if(!val)
			break;
		hour=atoi(val);
		while(val=strtok(NULL,sep))
		{
			count++;
			if(count==2)
				minute=atoi(val);
			if(count==3)
				second=atoi(val);
			if(count==4)
			{
				compute=false;
				speed=atof(val);
			}
		}
		mile+=(((hour-lh)*3600+(minute-lm)*60+(second-ls))*cs)/3600.0;
		if(compute)
		{
			if(hour<10)
				cout<<"0"<<hour<<":";
			else
				cout<<hour<<":";
			if(minute<10)
				cout<<"0"<<minute<<":";
			else
				cout<<minute<<":";
			if(second<10)
				cout<<"0"<<second<<": ";
			else
				cout<<second<<": ";
			cout<<setiosflags(ios::fixed) <<setprecision(2)<<mile<<" km"<<endl;
		}
	}
}

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