版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、题目: 银行业务活动的模拟 C+编写VS2008调试1. 题目要求假设某银行有4个窗口对外接待客户,从早晨银行开门起不断有客户进入银行,由于每个窗口在某个时刻只能接待一个客户。因此在客户人数众多时需要在每个窗口前顺次排队,对于刚进入银行的客户。如果某个窗口的业务员正空闲,则可上前输业务。反之,若个窗口均有客户所占,他便会排在为数最少的队伍后面。编制一个程序模拟银行的这种业务活动并计算一天中客户在银行的平均逗留时间。2. 实现功能功能要求:1).实现数据的输入;2).各个窗口数据的访问和输出;3)当前窗口的人员分布情况动态显示。界面要求:有合理的提示,每个功能可以设立菜单,根据提示,可以完成相关
2、的功能要求。存储结构:学生自己根据系统功能要求自己设计。请在最后的上交资料中指明你用到的存储结构;总体设计从题目要求不难得出,银行排队是典型的队列操作,4个窗口就是四个队列,客户的进出就是出队,入队操作,客户窗口的选择,以及平均逗留时间可以对队列的长度进行相应计算得出。因此,可以设计两个类,一个队列类,四个窗口就是四个队列对象,一个数据类,用于对客户排队编号的文件读取,写入,计算逗留时间。通过两个类的连接,实现数据的输入,动态显示。代码部分:/bank.h#includeiostream#includefstreamusing namespace std;int const SIZE=100;
3、struct nodeint num;node *next;class linkpublic:link();void add(int num);void dele();void print();int r_count();node* r_head();int r_rear();private:node *head,*rear,*front;int count;class datapublic:void write(node *head,int i);void read(int i);void wait(int count4);int num4SIZE,count_rear4;private:o
4、fstream we;ifstream re;/data函数.cpp#includeiostream#includefstream#includebank.husing namespace std;void data:write(node *head,int i)int aSIZE;int count=0;node *p=new node;if(head-next!=NULL)p=head-next;while(p!=NULL)acount=p-num;p=p-next;+count;switch(i)case 1:we.open(1.txt,ios_base:trunc|ios_base:b
5、inary);for(int i=0;icount;i+)we.write(reinterpret_cast(&ai),sizeof(ai); we.close(); break;case 2:ofstream we2;we2.open(2.txt,ios_base:in|ios_base:binary);for(int i=0;icount;i+)we2.write(reinterpret_cast(&ai),sizeof(ai); we2.close();break;case 3:ofstream we3;we3.open(3.txt,ios_base:in|ios_base:binary
6、);for(int i=0;icount;i+)we3.write(reinterpret_cast(&ai),sizeof(ai); we3.close();break;case 4:ofstream we4;we4.open(4.txt,ios_base:in|ios_base:binary);for(int i=0;icount;i+)we4.write(reinterpret_cast(&ai),sizeof(ai); we4.close();break;void data:read(int i)int j=0;switch(i)case 1:re.open(1.txt,ios_bas
7、e:binary|ios_base:in);while(!re.eof()re.read(reinterpret_cast(&numi-1j),sizeof(numi-1j);+j;count_reari-1=j;re.close();break;case 2:ifstream re2;re2.open(2.txt,ios_base:binary);while(!re2.eof()re2.read(reinterpret_cast(&numi-1j),sizeof(numi-1j);+j;count_reari-1=j;re2.close();break;case 3:ifstream re3
8、;re3.open(3.txt,ios_base:binary);while(!re3.eof()re3.read(reinterpret_cast(&numi-1j),sizeof(numi-1j);+j;count_reari-1=j;re3.close();break;case 4:ifstream re4;re4.open(4.txt,ios_base:binary);while(!re4.eof()re4.read(reinterpret_cast(&numi-1j),sizeof(numi-1j);+j; count_reari-1=j; re4.close(); break;vo
9、id data:wait(int count5)int ave,sum;ave=sum=0;cout假设每个客户办理业务的时间为 5 分钟,当前窗口排队人数为:endl;for(int i=0;i4;i+)couti+1号窗口:countiendl;for(int i=0;i4;i+)for(int j=1;jcounti;j+)ave=ave+j*5;for(int i=0;i4;i+)sum=sum+counti;ave=ave/sum;cout客户在银行平均逗留时间为:ave分钟endl;ave=0;cout是否返回上一层? 1 是 ave;/队列函数.cpp#includeiostre
10、am#includebank.husing namespace std;link:link()head=new node;head-next=NULL;rear=new node;rear-next=NULL; count=0;void link:add(int num)if(head-next=NULL)rear-num=num;head-next=rear;front=rear;elsenode *s=new node;s-num=num;s-next=NULL;rear-next=s;rear=s;count+;void link:dele()if(head-next!=NULL)hea
11、d-next=front-next; front=front-next;count-;cout该窗口一人办好业务,离队endl;elsecout业务窗口空闲next;cout窗口排队具体编号为:endl;while(p!=NULL)coutnumnext;coutendl;cout1 办好业务,离队1人 2 返回上一层i;if(i=1)dele();delete(p);int link:r_count()return count;node* link:r_head()return head;int link:r_rear()if(rear!=NULL)return rear-num;elsec
12、out窗口空闲endl; return 0;/main.cpp#includeiostream#includebank.husing namespace std;int main()link a4;data b;int count5,i,num=1;for(int i=1;i5;i+)b.read(i);for(int i=0;i4;i+)for(int j=0;jb.count_reari-1;j+)ai.add(b.numij);loop:system(CLS);cout 欢迎进入银行业务活动模拟系统endl;for(int i=0;i4;i+)counti=ai.r_count();co
13、ut1号窗口 2号窗口 3号窗口 4号窗口 endl;cout count0 count1 count2 count3endl;coutendl;cout1 查看具体窗口排队情况 2 插入排队人员 3 平均逗留时间 4 退出i;if(i=1)int i;cout请选择:1号窗口 2号窗口 3号窗口 4号窗口i;system(CLS);switch(i)case 1:a0.print();goto loop;break;case 2:a1.print();goto loop;break;case 3:a2.print();goto loop;break;case 4:a3.print();goto loop;break;else if(i=2)int i;cout请输入要排队办理业务的人数i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 山东省济南市高新区重点名校2026届初三语文试题下学期第一次月考语文试题含解析
- 河北省南宫市奋飞中学2026年初三下学期统练(一)英语试题含解析
- 河南省许昌市襄城县市级名校2025-2026学年初三下学期仿真考试(二)英语试题试卷含解析
- 湖北省孝感市孝南区部分校2026年初三九月摸底考试英语试题含解析
- 挖机挖土方合同
- 2026年棚菜用工合同(1篇)
- MT-T 264-2025 煤的显微维氏硬度测定方法
- 教案-铁的重要化合物
- 2026年医药第三方物流质量审计与方案
- 2026年会议活动签到处与注册区搭建方案
- 2026年及未来5年市场数据中国演艺行业市场发展数据监测及投资潜力预测报告
- 2026广西北海市从“五方面人员”中选拔乡镇领导班子成员25人考试备考题库及答案解析
- 商业银行公司治理评价表
- 社会福利院服务投标方案
- 国家开放大学电大专科《计算机平面设计(2)》网络课形考任务1及任务2答案
- 煤矸石路基施工工艺
- 住宅项目项目部实施计划书方案
- GB/T 2820.5-2009往复式内燃机驱动的交流发电机组第5部分:发电机组
- 食堂卫生工作检查表
- 特种经济动物生产学 第七章 鹿课件
- 质量在我心中,质量在我手中
评论
0/150
提交评论