#includeiostream#includewindows.h#includestring#includetime.h#includestdlib.husingnamespacestd;/******************窗口结构体********************/structWindows{intdeposit;/****************存款*****************/intwithdrawals;/****************取款*****************/intreportloss;/****************挂失*****************/intborrowed;/****************还贷*****************/intanum[1000];/**************保存客户***************/};/******************时间结构体********************/structTime{inthour;intminute;intsecond;};/******************票号结构体********************/structTicket{Timearrivaltime;/****************到达时间*****************/intnumber;/****************编号*****************/intbusiness;/****************办理业务*****************/};constintQueueSize=1000;classBankBusinses{public:BankBusinses();voidEnQueue();intGetQueue();voidPersonnel_Func(Tickett2[],intn,ints);/***************手动业务生成函数***************/intTicket_Produce_Function(Tickett[],intn);/***************打号函数***************/intPersonnel_Distribution_Func(intn,intflag);/***************业务办理函数***************/intBusiness_statistic_Func(Windowswin[],intm);/***************业务统计函数***************/voidDisplay_Business_Func(Windowswin[],intm,intn,intcoordinate);/***************业务显示函数***************/voidMake_waittime_Func(intn);/***************等待时间函数***************/intMenu();/***************菜单函数***************/Windowswin[4];/***************窗口***************/Tickett[QueueSize];/***************票***************/Tickett2[QueueSize];private:stringname;/***************业务名称***************/intbusinesstime;/***************办理业务所需时间***************/intalltime;/***************办理所有业务的总时间***************/intwaittime;/***************等待时间***************/doubleaveragetime;/***************平均等待时间***************/long*a,*b,*v;intdata[QueueSize];Ticketdata2[QueueSize];intfront,rear;};#includeBankBusinses.hBankBusinses::BankBusinses(){front=rear=QueueSize-1;}/*******************打号函数********************/intBankBusinses::Ticket_Produce_Function(Tickett[],intn){inttemp,sign,i,j=0;a=newlong[n];b=newlong[n];v=newlong[n];/*******************对时间排序********************/for(i=0;in;i++)for(j=i+1;jn;j++){if(t[i].arrivaltime.hourt[j].arrivaltime.hour){temp=t[i].arrivaltime.hour;t[i].arrivaltime.hour=t[j].arrivaltime.hour;t[j].arrivaltime.hour=temp;temp=t[i].arrivaltime.minute;t[i].arrivaltime.minute=t[j].arrivaltime.minute;t[j].arrivaltime.minute=temp;temp=t[i].arrivaltime.second;t[i].arrivaltime.second=t[j].arrivaltime.second;t[j].arrivaltime.second=temp;}}for(i=0;in;i++)for(j=i+1;jn;j++){if(t[i].arrivaltime.hour==t[j].arrivaltime.hour&&t[i].arrivaltime.minutet[j].arrivaltime.minute){temp=t[i].arrivaltime.minute;t[i].arrivaltime.minute=t[j].arrivaltime.minute;t[j].arrivaltime.minute=temp;temp=t[i].arrivaltime.second;t[i].arrivaltime.second=t[j].arrivaltime.second;t[j].arrivaltime.second=temp;}elsecontinue;}for(i=0;in;i++)for(j=i+1;jn;j++){if(t[i].arrivaltime.hour==t[j].arrivaltime.hour&&t[i].arrivaltime.minute==t[j].arrivaltime.minute&&t[i].arrivaltime.secondt[j].arrivaltime.second){temp=t[i].arrivaltime.second;t[i].arrivaltime.second=t[j].arrivaltime.second;t[j].arrivaltime.second=temp;}elsecontinue;}for(i=0;in;i++){a[i]=v[i]=t[i].arrivaltime.hour*3600+t[i].arrivaltime.minute*60+t[i].arrivaltime.second;}srand(time(0));for(i=0;in;i++){t[i].number=i;/************编号产生***********/rear=(rear+1)%QueueSize;data[rear]=t[i].number;sign=(rand()%(5-1))+1;t[i].business=sign;/************业务产生***********/switch(t[i].business){case1:name=取款;businesstime=1;break;case2:name=存款;businesstime=2;break;case3:name=挂失;businesstime=3;break;case4:name=还贷;businesstime=4;break;}b[i]=t[i].business*60;}returnn;}/*******************手动业务生成客户编号函数********************/voidBankBusinses::EnQueue(){intn,m;srand(time(0));while(front!=rear){n=(rand()%(200-1)+1);rear=(rear+1)%QueueSize;data2[rear].number=n;m=(rand()%(5-1))+1;data2[rear].business=m;/************业务产生***********/}}intBankBusinses::GetQueue(){inti=0;while(front!=rear){front=(front+1)%QueueSize;switch(t[front].business){case1:name=取款;businesstime=1;break;case2:name=存款;businesstime=2;break;case3:name=挂失;businesstime=3;break;case4:name=还贷;businesstime=4;break;}}returndata[front];}/*******************处理客户业务函数********************/intBankBusinses::Personnel_Distribution_Func(intn,intflag){inti,k=-1,j=0,m=0,g=0;inttransh,transm,transs,transb;longfirst=0,end=0,next=0,nend=0;longc[4]={-4,-3,-2,-1},temp;//c[4]作用是对应储存四个窗口业务办理结束的时间,在循环过程中后一个业务办理结束时间将修改当前结束时间Ticket_Produce_Function(t,n);//调用时间生成函数for(i=0;i4;i++){win[i].withdrawals=0;win[i].deposit=0;win[i].reportloss=0;win[i].borrowed=0;}c[0]=a[0]+b[0];//第一个窗口结束时间初值为队列中第一个客户办理业务的结束时间waittime=b[0];//第一个客户的逗留时间transh=a[0]/3600;transm=(a[0]%3600)/60;transs=(a[0]%3600)%60;transb=b[0]/60;switch(transb)//窗口各种业务累计{case1:win[0].withdrawals++;businesstime=1;break;case2:win[0].deposit++;businesstime=2;break;case3:win[0].reportloss++;businesstime=3;break;case4:win[0].borrowed++;businesstime=4;break;}v[0]=0;for(i=0;in;i++){int*d;d=newint[4];//动态申请长度为四的一维数组,用于存放被修改结束时