10281

Average Speed
Type:
General
Diff:2.5

Tricks

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:

  1. hp<-0, mp<-0,sp<-1 , kmh<-0, kmm <-0, kms <-0,distamce <-0
  2. while not found EOF
  3.              Take input h , m and s  //  h for hour, m for minute and s for second.
  4.              distance = distance + (h - hp)*kmh + (m-mp)*kmm + (s-sp)* kms;
  5.              get a character ch
  6.              if ch != �\n�
  7.                         get input k;
  8.             kmh <- k
  9.             kmm <- kmh / 60;
  10.             kms <- kmm / 60;
  11.             else
  12.                         print the distance
  13.              hp <- h;
  14.              mp <- m;
  15.              sp <- s;

Related Problems & Topics

 

If you have any advice, complements 

or proposal, please  Send mail to Author

Submit

 

1