銀行業(yè)務(wù)活動模擬__數(shù)據(jù)結(jié)構(gòu)_第1頁
銀行業(yè)務(wù)活動模擬__數(shù)據(jù)結(jié)構(gòu)_第2頁
銀行業(yè)務(wù)活動模擬__數(shù)據(jù)結(jié)構(gòu)_第3頁
銀行業(yè)務(wù)活動模擬__數(shù)據(jù)結(jié)構(gòu)_第4頁
銀行業(yè)務(wù)活動模擬__數(shù)據(jù)結(jié)構(gòu)_第5頁
已閱讀5頁,還剩14頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、題目: 銀行業(yè)務(wù)活動的模擬 C+編寫VS2008調(diào)試1. 題目要求假設(shè)某銀行有4個窗口對外接待客戶,從早晨銀行開門起不斷有客戶進入銀行,由于每個窗口在某個時刻只能接待一個客戶。因此在客戶人數(shù)眾多時需要在每個窗口前順次排隊,對于剛進入銀行的客戶。如果某個窗口的業(yè)務(wù)員正空閑,則可上前輸業(yè)務(wù)。反之,若個窗口均有客戶所占,他便會排在為數(shù)最少的隊伍后面。編制一個程序模擬銀行的這種業(yè)務(wù)活動并計算一天中客戶在銀行的平均逗留時間。2. 實現(xiàn)功能功能要求:1).實現(xiàn)數(shù)據(jù)的輸入;2).各個窗口數(shù)據(jù)的訪問和輸出;3)當前窗口的人員分布情況動態(tài)顯示。界面要求:有合理的提示,每個功能可以設(shè)立菜單,根據(jù)提示,可以完成相關(guān)

2、的功能要求。存儲結(jié)構(gòu):學(xué)生自己根據(jù)系統(tǒng)功能要求自己設(shè)計。請在最后的上交資料中指明你用到的存儲結(jié)構(gòu);總體設(shè)計從題目要求不難得出,銀行排隊是典型的隊列操作,4個窗口就是四個隊列,客戶的進出就是出隊,入隊操作,客戶窗口的選擇,以及平均逗留時間可以對隊列的長度進行相應(yīng)計算得出。因此,可以設(shè)計兩個類,一個隊列類,四個窗口就是四個隊列對象,一個數(shù)據(jù)類,用于對客戶排隊編號的文件讀取,寫入,計算逗留時間。通過兩個類的連接,實現(xiàn)數(shù)據(jù)的輸入,動態(tài)顯示。代碼部分:/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函數(shù).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假設(shè)每個客戶辦理業(yè)務(wù)的時間為 5 分鐘,當前窗口排隊人數(shù)為: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;/隊列函數(shù).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該窗口一人辦好業(yè)務(wù),離隊endl;elsecout業(yè)務(wù)窗口空閑next;cout窗口排隊具體編號為:endl;while(p!=NULL)coutnumnext;coutendl;cout1 辦好業(yè)務(wù),離隊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 歡迎進入銀行業(yè)務(wù)活動模擬系統(tǒng)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請輸入要排隊辦理業(yè)務(wù)的人數(shù)i

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論