Mobigic | Onsite | Travelling Delivery boy
Anonymous User
1131
       __       __       __       __       __       __       __       __
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
      |__|     |__|     |__|     |__|     |__|     |__|     |__|     |__|
G_____|  |_____|  |_____|  |_____|  |_____|  |_____|  |_____|  |_____|  |
  1. Assume there is a society of Multiple buildings.
  2. All the buildings are in a row and with same number of floors.
  3. The distance between every consecutive building is same. (consider it as 1 unit)
  4. The society can be access only after crossing the Security gate (marked as G)
  5. The distance between Security gate and 1st building is also considered as 1 unit.
  6. The distance between every consecutive floors is also to be considered as 1 unit.
  7. Consider a delivery boy who arrives at the Security Gate to perform delivery of items at various flats in the society.
  8. We have to calculate the distance that the Delivery Boy needs to travel to deliver All the parcels. The calculation of the distance has to start from the Security Gate G and must end at Security Gate G when he returns.

Write a program which will seek following inputs from the user:

  1. Number of buildings in the society
  2. Number of floors in a building.
  3. Total number of parcels to be delivered
  4. For each parcel, the delivery location (each location to be considered as a-b where a is the building number and b is the floor number).
  5. The program should output the total distance to be travelled by the Delivery Boy.
Comments (2)