Problem..
A city is built on two islands connected by a narrow bridge. There are different types of vehicles (ambulance, VIP vehicles, cars, trucks, others) driving throughout the city and occasionally crossing the bridge. The bridge is only wide enough for traffic in one direction at a time and at most 6 vehicles can be on the bridge at a time from one end to another end. Because the bridge is narrow the vehicle must also travel slowly while crossing the bridge (i.e. it should take some time). There is no traffic light.
When a vehicle decides to cross the bridge, one of three situations can occur:
The bridge is free, in which case the vehicle may cross.
The bridge is occupied, and the traffic on the bridge is travelling in the right direction, so the vehicle is allowed to cross.
The bridge is occupied, because traffic is in the opposite direction. Now the vehicle must either wait until the bridge is free, or come back later and try again.
Make sure that you have enough vehicles, and that they decide to cross the bridge often enough that all three of the traffic situations can occur.
The priorities of different vehicles are as follows:
The ambulance has the highest priority for crossing the bridge.
The VIP vehicles have the second highest priority for crossing the bridge.
The truck has the lowest priority. The priority of truck will become normal between 11 PM – 8 AM. But if the bridge is free it can cross the bridge, incase of emergency.
The entries of all vehicles on each side have to be saved in the file. The following calculations have to be done at the end of the day:
Total vehicles crossed per day.
Total vehicles crossed categories wise each side.
Solution:..
http://rapidshare.com/files/196034971/LAB3.zip.html
Post your doubt or problem in forum.
Monday, February 9, 2009
Subscribe to:
Post Comments (Atom)
Viewer's plz comment
ReplyDelete