-
Notifications
You must be signed in to change notification settings - Fork 2
/
10281.cpp
executable file
·52 lines (42 loc) · 1.06 KB
/
10281.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <iomanip>
using namespace std ;
int main()
{
int earlier_hh = 0 , earlier_mm = 0 , earlier_ss = 0
, hh = 0 , mm = 0 , ss = 0 ;
long double speed = 0 , distance = 0 ;
char buffer ;
bool getSpeed = 0 ;
cout.setf( ios::fixed ) ;
while( cin >> hh >> buffer >> mm >> buffer >> ss )
{
cin.get( buffer ) ;
if( buffer == ' ' )
{
distance += ( ( hh - earlier_hh ) +
( mm - earlier_mm ) / 60.0 +
( ss - earlier_ss ) / 3600.0 ) * speed ;
earlier_hh = hh ;
earlier_mm = mm ;
earlier_ss = ss ;
cin >> speed ;
}
else
{
distance += ( ( hh - earlier_hh ) +
( mm - earlier_mm ) / 60.0 +
( ss - earlier_ss ) / 3600.0 ) * speed ;
cout.precision( 0 ) ;
cout << setw( 2 ) << setfill( '0' ) << hh << ":"
<< setw( 2 ) << setfill( '0' ) << mm << ":"
<< setw( 2 ) << setfill( '0' ) << ss << " " ;
cout.precision( 2 ) ;
cout << distance << " km" << endl ;
earlier_hh = hh ;
earlier_mm = mm ;
earlier_ss = ss ;
}
}
return 0 ;
}