The calculation is very easy. Take care
about output. For output 03 or 00 or any other number less then 10,
print first a 0 (zero) then print the number. To calculate the result,
first I break the speed into km/h, km/m and km/s. Then I calculate the
distance. The algorithm of this problem is as follows:
- hp<-0, mp<-0,sp<-1 , kmh<-0, kmm <-0, kms
<-0,distamce <-0
- while not found EOF
- Take
input h , m and s // h for
hour, m for minute and s for second.
- distance
= distance + (h - hp)*kmh + (m-mp)*kmm + (s-sp)* kms;
- get
a character ch
- if
ch != �\n�
-
get input k;
-
kmh <- k
-
kmm <- kmh / 60;
-
kms <- kmm / 60;
- else
-
print the distance
- hp
<- h;
-
mp <- m;
-
sp <- s;
|