main.cpp

来自「数据结构」· C++ 代码 · 共 40 行

CPP
40
字号
#include"event.h"
#include"random.h"
#include"arriveEvent.h"
#include"customergroup.h"
#include"storeSimulation.h"

#include<assert.h>
#include<iostream.h>

const int seatnum=10;
const int hour=8;


storeSimulation store(seatnum);
void iceCreamStoreSimulation();


void main()
{
	cout<<"       "<<"冰淇淋店"<<endl;
	cout<<seatnum<<"个座位,营业"<<hour<<"小时"<<endl;
	
	iceCreamStoreSimulation();
}

void iceCreamStoreSimulation()
{  	
    for(unsigned int time=0;time<(hour*60);time+=randgen.between(1,10))
    {
		customerGroup*group=new customerGroup;
		
		assert(group!=0);
		event* ae=new arriveEvent(time,group);
		assert(ae!=0);
		store.scheduleEvent(ae);
    }
    store.run();
    store.printProfits();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?