C++银行业务模拟系统

上传人:仙*** 文档编号:33278314 上传时间:2021-10-16 格式:DOC 页数:13 大小:66KB
返回 下载 相关 举报
C++银行业务模拟系统_第1页
第1页 / 共13页
C++银行业务模拟系统_第2页
第2页 / 共13页
C++银行业务模拟系统_第3页
第3页 / 共13页
点击查看更多>>
资源描述
#include#include#include#include using namespace std;const int aa=70,bb=150,cc=130,dd=50;/不同业务所需时间struct data/客户资料 int usetime;/客户在银行时间 int bianhao;/客户编号 int yewutime;/客户所办业务时间 string yewu;/业务名 int yewunum;/业务标号 int chutime3;/客户到达时间,chutime0是秒钟,chutime1是分钟,chutime2是时钟 int motime3;/客户离开时间 int windownum;class Bankprivate: int windowsum45; /窗口数 long sumtime; /所有办理完业务客户总共所用时间 int suijitime; /最后两个客户间隔时间 int stilltime4; /每个窗口还需等待时间 int s,f,m; /分别是时、分、秒 int wind5; /wind0是空闲窗口数量,wind1/2/3/4存放具体窗口名 public: Bank(); /初始化 data kehu900; /8小时内最多客户人数 void timelocal(Bank &); /记录时间 int windows(int,int); /为客户排队 void calculatechu(int,Bank&);/记录客户到达时间 void print(int,int ,Bank); /输出客户数据 void averagetime(int,Bank); /计算平均时间 void window_dail(); /输出窗口信息 int fanhui(Bank &); /求随机时间 void custerm_dail(int,int,Bank);/选择客户编号 void choose(int,int,Bank); /选择查看内容 void todaynum(int,int,Bank);/显示今日客户量 void writetotext(int,Bank);/文件函数操作;Bank:Bank()/构造 s=8;/时间 f=0; m=0; suijitime=0; /随机间隔时间 sumtime=0; /所有客户在银行所用时间之和 for(int i=0;i4;i+) stilltimei=0; /每个窗口处理剩下业务还需要的时间 for(int j=0;j5;j+) windowsumij=0; /每个窗口处理客户数 for(int a=0;a=1) /完成时间格式 m=m-60;f+; while(f/60=1) f=f-60;s+; return s;void Bank:timelocal(Bank &wait) /记录银行时间 cout您到达的时间是: ; if(s10)cout0s:;/特定格式输出 else couts:; if(f10)cout0f:; else coutf:; if(m10)cout0mendl; else coutmendl; void Bank:averagetime(int x,Bank wait)/计算所有客户的平均等待时间 long aver=0;/平均时间 int fen=0,miao=0;/平均时间以分、秒表示 int j; sumtime=0; for(j=0;jx;j+) sumtime=sumtime+wait.kehuj.usetime;/总共时间 aver=sumtime/(x);/计算 fen=aver/60; miao=aver; cout所有客户平均等待了 fen分miao秒!endlendl;/求空窗口数int Bank:windows(int x,int i)/x是办理业务的客户数,i是最后一位顾客的编号,wait是主函数里定义的对象 int a,b=1,t=0; for(a=0;a5;a+)/初始化窗口空闲信息 winda=0; for(a=0;a4;a+) stilltimea=stilltimea-suijitime;/特定窗口处理还需的时间等于上次处理所需的时间减去随机等待时间 if(stilltimea=0) /如果时间为负,重新赋值 stilltimea=0; wind0+; /空余窗口数 windb+=a+1; /指出特定的空闲窗口 t=wind0; b=1; while(x0) /窗口不空 stilltimewindb-1=stilltimewindb-1+kehux.yewutime;/特定窗口处理完业务所需时间等于 处理完上次业务所需时间 加上 此次业务时间 kehux.motime0=m;/客户离开时的秒钟 kehux.motime1=f;/客户离开时的分钟 kehux.motime2=s;/客户离开时的时钟 kehux.usetime=kehux.motime0-kehux.chutime0+(kehux.motime1-kehux.chutime1)*60+(kehux.motime2-kehux.chutime2)*3600+kehux.yewutime;/客户在银行等待时间 windowsumwindb-10+;/特定窗口处理的客户数 windowsumwindb-1kehux.yewunum+; /特定窗口处理的业务数 b+;x+;t-; return x;void Bank:calculatechu(int i,Bank &Custerm)/客户的到达时间 int j; for(j=0;j=60) sec=sec-60; min+; while(min=60) min=min-60; hour+; cout以下是Custerm.kehux.bianhao号客户的详细资料:endl; cout选择的业务:Custerm.kehux.yewuendl; cout选择的业务所需的时间:Custerm.kehux.yewutimeendl; cout0;k-) if(Custerm.kehux.chutimek10)cout0Custerm.kehux.chutimek:; else coutCusterm.kehux.chutimek:; if(Custerm.kehux.chutime010)cout0Custerm.kehux.chutime0; else coutCusterm.kehux.chutime0; coutendl; cout客户离开的时间:; if(hour10)cout0hour:;/特定格式输出 else couthour:; if(min10)cout0min:; else coutmin:; if(sec10)cout0secendl; else coutsecendl; coutendl;void Bank:window_dail()/输出窗口办理业务的情况 int i; while(1) cout请选择窗口(1-4),以0结束:i; if(i=0)system(cls);break; if(i=5)system(cls);cout没有这个窗口,请重新选择endl; else system(cls); cout i窗口共处理了 windowsumi-10人endl; cout其中endl; cout 存款业务 windowsumi-11人endl; cout 取款业务 windowsumi-12人endl; cout 挂失业务 windowsumi-13人endl; cout 还贷业务 windowsumi-14人endl; void Bank:todaynum(int x,int i,Bank Custerm)/输出客户量 coutendl 今日共来了i位客户!endl; cout 其中,处理了x位客户,还有i-x位客户未得到处理!endlendl;void Bank:custerm_dail(int i,int x,Bank Custerm)/选择输出的客户编号 int h; while(1) couth; if(h=0)couti) system(cls); cout没有这个编号,请重新选择!endlx&hi) system(cls); cout银行停业前未处理该客户!endlendl; else system(cls);print(h-1,i,Custerm); void Bank:choose(int x,int i,Bank Custerm)/选择输出详细信息 int n; int flag=0; while(1) cout endl; coutendl; cout 0 退出 endlendl; cout 1 查看今日银行客户数量 endlendl; cout 2 第n号窗口的详细信息 endlendl; cout 3 客户平均等待时间 endlendl; coutendl; cout endlendl; coutn; switch(n) case 0:flag=1;break; case 1:system(cls);todaynum(x,i,Custerm);system(pause);system(cls);break; case 2:system(cls);window_dail();break; / case 3:system(cls);custerm_dail(i,x,Custerm) ;break; case 3:system(cls);averagetime(x,Custerm);system(pause);system(cls);break; default:system(cls);cout没有这个选项,请重新选择!=60) sec=sec-60; min+; while(min=60) min=min-60; hour+; coutch; if(ch=y) if(x=0)cout数据记录为空!endl; else ofstream outfile(f1.txt,ios:out); if(!outfile) cout打开失败endl; exit(1); while(jx) outfile * * * * * * * * * * endl; outfile 客户编号: kehuj.bianhaoendl; outfile 办理业务: kehuj.yewuendl; outfile 业务时间: kehuj.yewutimeendl; outfile 到达时间: ; if(kehuj.chutime210)outfile0kehuj.chutime2:; else outfilekehuj.chutime2:; if(kehuj.chutime110)outfile0kehuj.chutime1:; else outfilekehuj.chutime1:; if(kehuj.chutime010)outfile0kehuj.chutime0:endl; else outfilekehuj.chutime0:endl; outfile=60) sec=sec-60; min+; while(min=60) min=min-60; hour+; if(hour10)outfile0hour:; else outfilehour:; if(min10)outfile0min:; else outfilemin:; if(sec10)outfile0sec:endl; else outfilesec:endl; j+; outfile.close(); cout成功生成文件!endl; int main () int ff; time_t t = time(0); /时间函数 char tmp64; int x=0,i=0; /i是最后到的客户编号 int flag1=1,flag=1,flag2=1; /x排在最前面的客户编号,flag1是第一次选项的关键标志,flag标志 int s=8; /16:00之前营业,s是时钟,m是最后两位客户间隔时间 int ch; Bank Custerm; string a=存款,b=取款,c=挂失,d=还贷;/业务名 while(flag1) coutendl; cout endl; coutendl; cout 0:退出 endl; cout 1:随机结果 endl; cout 2:输入业务 endl; cout 3:从文件读入endl; cout endl; cout 请选择: ; scanf(%d,&ch); switch(ch) case 0: exit(0); case 1: flag=0;/选择是否使用系统暂停函数 flag1=0;/停止本项选择 break; case 2: flag1=0; break; /*case 3: flag1=0; break; */ default: cout 没有这个选项,请重新选择!endl; system(pause); break; system(cls); while(s) coutendl; coutendl; cout endl; coutendl; cout endl; cout 欢迎来到小辉辉银行 endl; cout endl; cout endl; cout 1:存 款 endl; cout 2:取 款 endl; cout 3:挂 失 endl; cout 4:还 贷 endl; cout 0:退 出 endl; coutendl; cout ff; else ff=(rand()%4+1);/随机选择4种业务 switch(ff) case 0:system(cls);break; case 1: coutendl; cout* * * * * * * * * * * * * * * =16) flag2=0; break; Custerm.kehui.bianhao=i+1;/赋值编号 Custerm.kehui.yewu=a;/赋值业务名 Custerm.kehui.yewunum=1;/赋值业务编号 Custerm.kehui.yewutime=aa;/赋值业务所用时间 Custerm.timelocal(Custerm);/16:00之前营业,s是时钟 Custerm.calculatechu(i,Custerm);/计算到达时间 x=Custerm.windows(x,i);/x是排在前面的顾客编号 i+; coutendl您的号码是: i 办理的是: aendlendl; cout您前面还有i-x位客户endlendl; break; case 2: coutendl; cout* * * * * * * * * * * * * * * =16) flag2=0; break; Custerm.kehui.bianhao=i+1; Custerm.kehui.yewu=b; Custerm.kehui.yewunum=2; Custerm.kehui.yewutime=bb; Custerm.timelocal(Custerm); Custerm.calculatechu(i,Custerm); x=Custerm.windows(x,i); i+; coutendl您的号码是: i 办理的是: bendlendl; cout您前面还有i-x位客户endlendl; break; case 3: coutendl; cout* * * * * * * * * * * * * * * =16) flag2=0; break; Custerm.kehui.bianhao=i+1; Custerm.kehui.yewu=c; Custerm.kehui.yewunum=3; Custerm.kehui.yewutime=cc; Custerm.timelocal(Custerm); Custerm.calculatechu(i,Custerm); x=Custerm.windows(x,i); i+; coutendl您的号码是: i 办理的是: cendlendl; cout您前面还有i-x位客户endlendl; break; case 4: coutendl; cout* * * * * * * * * * * * * * * =16) flag2=0; break; Custerm.kehui.bianhao=i+1; Custerm.kehui.yewu=d; Custerm.kehui.yewunum=4; Custerm.kehui.yewutime=dd; Custerm.timelocal(Custerm); Custerm.calculatechu(i,Custerm); x=Custerm.windows(x,i); i+; coutendl您的号码是: i 办理的是: dendlendl; cout您前面还有i-x位客户endlendl; break; default: cout没有这个选项!endl; break; if(ff=0) break; if(flag=1) system(pause); system(cls); if(flag2=0) break; Custerm.choose(x,i,Custerm); Custerm.writetotext(x,Custerm); return 0;
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!