文件名称:复件 轮渡问题
介绍说明--下载内容来自于网络,使用问题请自行百度
1. 汽车轮渡口,过江渡船每次能载10辆车过江,过江车辆分为客车类和货车类,上渡船有如下规定:同类车先到先上船,客车先于货车上渡船,且每上4辆客车,才允许上一辆货车。若等待客车不足4辆,则从货车代替,若无货车等待允许客车上船。试写一个算法模拟渡口管理。
算法设计:
1客车和货车均建立一个链式队列,初始均为空。以后来一辆车不是货车就是客车,因此可以说整个程序的事件驱动event就是这两个,客车表示1,货车表示0.
2轮船还没有到达时客车和货车均按次序排在各自队列中。
3轮船到达时,根据两个队列的情况,分别处理。处理如下:
a 客车数不满4辆,则将排在前面的货车上船,但总数不能超过10,若没有货车等待,客车直接上船。
b 客车数满4,但不满8辆,客车先上,排在前面的只有一辆货车可以上船,若没有货车等待则货车不上。
c 客车满8辆但不满10,客车上船,排在前面的货车最多可以上2辆,但总数不能超过10。
d 客车满10,则全上客车,但总数不能超过10。
-1. I car ferry, crossing the river each ferry can carry 10 cars crossing the river, crossing the river into passenger vehicles and goods category, Ferry on the following provisions : first vehicle in a first embarkation, the first passenger ferry in the truck and four on each passenger will be permitted on a lorry. If waiting for the bus less than four, then replace the truck, without waiting for the lorry to allow passenger embarkation. Try to write a simulated crossing management. Algorithm design : a bus and the truck were established a chain cohort, the initial were empty. Later, a car is not a passenger vehicle is, it can be said of the entire process event-driven event is the two, said a passenger, said the lorry 0. Two ships have not yet arrived at the bus and the truck were ranked
算法设计:
1客车和货车均建立一个链式队列,初始均为空。以后来一辆车不是货车就是客车,因此可以说整个程序的事件驱动event就是这两个,客车表示1,货车表示0.
2轮船还没有到达时客车和货车均按次序排在各自队列中。
3轮船到达时,根据两个队列的情况,分别处理。处理如下:
a 客车数不满4辆,则将排在前面的货车上船,但总数不能超过10,若没有货车等待,客车直接上船。
b 客车数满4,但不满8辆,客车先上,排在前面的只有一辆货车可以上船,若没有货车等待则货车不上。
c 客车满8辆但不满10,客车上船,排在前面的货车最多可以上2辆,但总数不能超过10。
d 客车满10,则全上客车,但总数不能超过10。
-1. I car ferry, crossing the river each ferry can carry 10 cars crossing the river, crossing the river into passenger vehicles and goods category, Ferry on the following provisions : first vehicle in a first embarkation, the first passenger ferry in the truck and four on each passenger will be permitted on a lorry. If waiting for the bus less than four, then replace the truck, without waiting for the lorry to allow passenger embarkation. Try to write a simulated crossing management. Algorithm design : a bus and the truck were established a chain cohort, the initial were empty. Later, a car is not a passenger vehicle is, it can be said of the entire process event-driven event is the two, said a passenger, said the lorry 0. Two ships have not yet arrived at the bus and the truck were ranked
(系统自动生成,下载前可以参看下载内容)
下载文件列表
复件 轮渡问题
复件 轮渡问题/汽车轮渡口算法设计.txt
复件 轮渡问题/test2.cpp
www.dssz.com.txt
复件 轮渡问题/汽车轮渡口算法设计.txt
复件 轮渡问题/test2.cpp
www.dssz.com.txt
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.