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 Judas at 2005-10-10 10:24:10 on Problem 2501
In Reply To:这是我的调试程序,有空的帮我看一看,第一行没有速度我考虑了,24点到0点我也考虑了,怎么还会错????? Posted by:xiaol at 2005-10-10 08:39:36
> #include <iostream>
> #include <string>
> #include <fstream>
> using namespace std;
> double second(string s) {
>     double time=0;
>     time+=((s[0]-'0')*10+s[1]-'0')*3600;
>     time+=((s[3]-'0')*10+s[4]-'0')*60;
>     time+=(s[6]-'0')*10+s[7]-'0';
>     return time;
> }    
> int main() {
>     fstream inf;
>     inf.open("abc.txt",ios::in);
>     string s;
>     char c;
>     double speed;
>     double time;
>     double  dis;
>     double temp;
>     int flag=0;
>     while(inf>>s && inf.get(c)) {
>         if(c==' ')break;
>     }
>     inf>>speed;    
>     time=second(s); dis=0;
>     while(inf>>s) {    
>         inf.get(c);
>         temp=second(s);
>         if(flag==3600) temp+=flag;
>         else if(temp<time) {
>             flag=3600;
>             temp+=flag;
>         }           
>         dis+=(temp-time)*speed/3600;
>         time=temp;
>         if(c==' ') {
>             inf>>speed;
>         }
>         else {
>             cout<<s<<' ';
>             printf("%.2f km\n",dis);
>         }
>     }
>     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