1 #include<iostream> 2 #include<iomanip> 3 #include<stdio.h> 4 #include<string> 5 #include<math.h> 6 using namespace std; 7 8 int main() 9 { 10 //freopen("acm.acm","r",stdin); 11 string s; 12 int i; 13 double speed = 0.0; 14 double road; 15 double time; 16 double time1; 17 double past; 18 time = 0; 19 past = 0; 20 road = 0; 21 getline(cin,s); 22 time = (double(s[0]-‘0‘)*10.0+double(s[1]-‘0‘))+(double(s[3]-‘0‘)*10.0+double(s[4]-‘0‘))/60.0+(double(s[6]-‘0‘)*10.0+double(s[7]-‘0‘))/3600.0; 23 if(s.length() > 8) 24 { 25 for(i = 9; i < s.length(); ++ i) 26 { 27 speed = speed*10.0 + double(s[i]-‘0‘); 28 } 29 } 30 else 31 { 32 cout<<s<<" "<<"0.00 km"<<endl; 33 } 34 time *= 60; 35 while(getline(cin,s)) 36 { 37 if(s.length() > 8) 38 { 39 time1 = (double(s[0]-‘0‘)*10.0+double(s[1]-‘0‘))+(double(s[3]-‘0‘)*10.0+double(s[4]-‘0‘))/60.0+(double(s[6]-‘0‘)*10.0+double(s[7]-‘0‘))/3600.0; 40 time1 *= 60.0; 41 past += speed*(time1-time); 42 time = time1; 43 speed = 0; 44 for(i = 9; i < s.length(); ++ i) 45 { 46 speed = speed*10.0 + double(s[i]-‘0‘); 47 } 48 } 49 if(s.length() == 8) 50 { 51 time1 = (double(s[0]-‘0‘)*10.0+double(s[1]-‘0‘))+(double(s[3]-‘0‘)*10.0+double(s[4]-‘0‘))/60.0+(double(s[6]-‘0‘)*10.0+double(s[7]-‘0‘))/3600.0; 52 time1 *= 60.0; 53 cout<<s<<‘ ‘; 54 cout<<setiosflags(ios::fixed)<<setprecision(2)<<(speed*(time1-time)+past)/60.0<<‘ ‘<<"km"<<endl; 55 } 56 } 57 58 }
时间: 2024-10-23 21:56:31