源码简介: |
设停车场是一个可停放n辆汽车的狭长通道,且只有一个大门可供 汽车进出。汽车在停车场内按车辆到达时间的先后顺序,依次由北向 南排列(大门在最南端),若停车场内已停满n辆汽车,则后来的汽车 只能在门外的便道上等候,一旦有车开走,则排在便道上的第一辆车即 可开入;当停车场内某辆车要离开时,在它之后进入的车辆必须先退出 车场为它让路,待该辆车开出大门外,其他车辆再按原次序进入车场, 每辆停放在车场的车在它离开停车场时必须按它停留的时间长短交纳费 用。试为停车场编制按上述要求进行管理的模拟程序。-Parking lots is a narrow channel n cars parking, and only one door for car out. Arrival sequence of cars in the parking lot by vehicle, sequentially arranged from north to south (the door at the southernmost tip), n cars parked within the parking, the later cars waiting outside on the sidewalk only Once drove off, the row of the first car on the sidewalk, you can open into When parking a car to leave, to enter the vehicle after it must first leave the yard to make way for it, until the car outside the gate opened, other vehicles and press the original order to enter the yard, each must pay the costs of the length of time it stays in when it left the parking lot of the car parked in the yard. Test for the car park of the simulation program for the management of the above-mentioned requirements.
|