C++程序代码-事件驱动模拟
#include
//getch #include"simulation.h"
Simulation::Simulation(void)//模拟过程初始化
{
cout<<"Enter the simulation time in minutes:";//从终端读取数据
cin>>SimulationLength;
cout<<"Enter the number of tellers(2~10):";
cin>>numTellers;
cout<<"Enter the range of arrival times in minutes:";
cin>>arrivalLow>>arrivalHigh;
cout<<"Enter the range of service times in minutes:";
cin>>serviceLow>>serviceHigh;
for(int i=1;i<= numTellers;i++) //窗口信息初始化
{
t[i].totalCustomer=0;
t[i].totalService=0;
t[i].totalWait=0;
}
PQ.Push(Event(0,0)); //一个客户于0时到达
}
Simulation::Simulation(int L,int nT,int aL,int aH,int sL,int sH)
{
SimulationLength=L;
numTellers=nT;
arrivalLow=aL;
arrivalHigh=aH;
serviceLow=sL;
serviceHigh=sH;
for(int i=1;i<=numTellers;i++) //窗口信息初始化
{
t[i].totalCustomer=0;
t[i].totalService=0;
t[i].totalWait=0;
}
PQ.Push(Event(0,0)); //一个客户于0时到达 }
int Simulation::GetNextTeller(void)//计算下一个可用窗口 {
int i,size=Q[1].Size(),min=1;
for(i=2;i<=numTellers;i++)
if(Q[i].Size()
表
关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf
{
s=Q[i].Front();
PQ.Push(Event(e.GetTime()+s.serviceTime,i));
}
}
void Simulation::PrintPQueue(void) //显示事件表
{
int n=PQ.Size(); //记录事件表长度
int i=0;
Event e,*p=new Event[n]; //建立动态数组
cout<<"*****EventQueue*****\n";
while(!PQ.Empty())
{
e=PQ.Pop(); //取出事件表一元素输出
cout<<'('<
本文档为【C++程序代码-事件驱动模拟】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。