源代码:
#include <iostream>
#include<stdio.h>
#include <string>
#include <conio.h>
#include <time.h>
#include<string.h>
#include<windows.h>
#include<stdlib.h>
using namespace std;
void welcome(void)
{
cout<<"*******************************************************************************"<<endl;
cout<<" 欢迎进入银行系统"<<endl;
cout<<"*******************************************************************************"<<endl;
cout<<" %%%%%%"<<endl;
cout<<" %%/\\%%%%/\\%% ╭───────╮ "<<endl;
cout<<" %%% "" %%% │ │ "<<endl;
cout<<" % %%%%/ o o \\%%% │请输入您的信息│ "<<endl;
cout<<" %% %%%% _ |%%% ╭╮│ │ "<<endl;
cout<<" `%% %%%%(__Y__)%% ╰╯╰───────╯ "<<endl;
cout<<" %% %%%%-%%% ○ "<<endl;
cout<<" %% / %%%%%%% ○"<<endl;
cout<<" \\\\ / |"<<endl;
cout<<" \\\\ / \\ | |"<<endl;
cout<<" \\\\/ ) | |"<<endl;
cout<<" \\ /_ | |__"<<endl;
cout<<" (___________)))))))"<<endl;
}
void denlu(void)
{
Sleep(200);
printf("●");
Sleep(200);
printf("●");
Sleep(200);
printf("●");
Sleep(200);
printf("●");
Sleep(200);
printf("●");
Sleep(200);
printf("●");
Sleep(200);
printf("●");
Sleep(200);
printf("●");
Sleep(200);
printf("●\n");
Sleep(1000);
printf("◆◆");
Sleep(1200);
printf("◆◆◆◆");
Sleep(1320);
printf("◆◆");
Sleep(1520);
printf("◆◆◆◆◆◆◆\n");
Sleep(1000);
printf("◆◆◆");
}
struct service
{
int num; //客户号
string type; //到达或离开
int beginTime;//到达时间
int endTime;//离开时间
int money; //正数为存款,负数为取款
service* next;//指针域
};
struct queue //队列
{
service* head;//队列头指针
service* rear;//队列尾指针
};
int total; //初始时银行现存资金总额
int closeTime; //营业结束时间
int arriveMaxTime; //两个到达事件之间的间隔上限
int arriveMinTime; //两个到达事件之间的间隔下限
int dealMaxTime; //客户之间交易的时间上限
int dealMinTime; //客户之间交易的时间下限
int dealMaxMoney ; //交易额上限
int ndn=0;//需要存款的人数
int nwn=0;//需要取款的人数
int sdn=0;//成功存款的人数
int swn=0;//成功取款的人数
int currentTime = 0; //当前时间
int totalTime = 0; //客户逗留总时间
int counter = 0; //客户总数
int number = 1; //初始客户序列号
bool state =1; //用于判断是否有窗口在处理
int currentTimeOfDeal = 0;//交易时间
int thearriveMaxTime = 0;//最大到达时间
queue eq; //事件队列
queue fq; //队列一
queue sq; //对列二
//初始化三个队列
service* front(queue &q)//返回队首元素
{
return q. head;
}
service* back(queue &q)//返回队尾元素
{
return q. rear;
}
void push(queue &q,int d)//入队列函数,插入元素d为队列q的新的队尾元素
{
service* temp = new service;
temp->money = d;
temp->next = NULL;
if(q.head==NULL)//队列为空,初始化
{
q. head = temp;
q. rear = temp;
}
else//队列不为空&