




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、各專業(yè)完整優(yōu)秀畢業(yè)設計圖紙?zhí)m州商學院隴橋學院信息工程系課程設計報告設 計 題 目:銀行業(yè)務模擬與離散事件模擬系 別:信息工程系 專 業(yè) (方 向):網(wǎng)絡工程年級、班:13級網(wǎng)絡工程學生姓名:學生學號:20130672122指導教師:2014年12月30日目錄一、系統(tǒng)開發(fā)的背景3二、系統(tǒng)分析與設計3(一)系統(tǒng)功能要求3(二)系統(tǒng)模塊結構設計4三、系統(tǒng)的設計與實現(xiàn)5(一)測試closeforday()函數(shù)5(二)測試customerarrived()函數(shù)5四、系統(tǒng)測試7五、總結9六、附件(代碼、部分圖表)10銀行業(yè)務模擬與離散事件模擬一、系統(tǒng)開發(fā)的背景1.通過此次課程設計中銀行業(yè)務模擬的題目,掌握
2、隊列(或者鏈表) 等數(shù)據(jù)結構的基本操作方面的知識,并能靈活的解決一些基本的問題,加深對其性質及各項操作的理解;2.將所學數(shù)據(jù)結構方面的知識與一門具體的語言相結合(語言)來進行實現(xiàn),感受數(shù)據(jù)結構的強大作用,加深理解。二、系統(tǒng)分析與設計(一)系統(tǒng)功能要求程序中用到的所有抽象數(shù)據(jù)類型的定義、主程序的流程以及各程序模塊之間的層次(調用)關系。使用到帶頭結點鏈表和結點,此鏈表用于存放客戶的進入或者離開的事件,存放數(shù)據(jù)包括進入的時間,處理的時間,離開的時間。使用一個隊列和節(jié)點,此隊列用于模擬進入銀行后等待辦理業(yè)務的客戶排隊情況。其存儲的數(shù)據(jù)有時間到達的時間和處理事物所需的時間。包括函數(shù)調用,主要的程序在m
3、ain.cpp中,從main()進入調用。首先,分析題目要求劃分實現(xiàn)模塊、畫出大致的流程圖,定義基本數(shù)據(jù)類型,諸如結構體、隊列等;其次,考慮基本大致的操作,比如要擬定開門的時間、顧客到來為其提供服務以及離開時的操作等;再次,針對上述的基本操作實現(xiàn)具體需要進行的操作,具體實現(xiàn)每個環(huán)節(jié)需要進行的基本操作,即具體編寫每個小函數(shù)實現(xiàn)功能;最后,編寫主函數(shù)對每個實現(xiàn)進行按需調用,實現(xiàn)操作。(二)系統(tǒng)模塊結構設計通過對系統(tǒng)功能的分析,銀行業(yè)務模擬和離散事件模擬功能如圖所示。圖1 程序流程圖三、系統(tǒng)的設計與實現(xiàn)(一)測試closeforday()函數(shù)voidcloseforday()printf(*n);p
4、rintf(*n);printf(* 所有顧客業(yè)務辦理總時間:%d分鐘n, totaltime);printf(* 業(yè)務辦理顧客數(shù):%dn, customernum);printf(* 平均每人辦理時間:%fn,(float)totaltime/(float)customernum);printf(*n);printf(*n);圖2 測試closeforday()函數(shù)(二)測試customerarrived()函數(shù)status customerarrived(eventlist&ev, qcupp&q, qcuevent en)test(顧客到達處理);customernum +;/ 產生隨機
5、數(shù)/srand(54);intdurtime = rand()%30+1;intintertime = rand()%5+1; / 插入到達事件表qcuevententemp;int t = en.occurtime + intertime;entemp.occurtime = t;entemp.ntype = 0;entemp.next = null;if (t arrivaltime = en.occurtime;q-duration = durtime;q-next = null;int i = mincuqueue(q);encuqueue(qi,q); / 插入離開事件entemp.
6、occurtime = en.occurtime + durtime;entemp.ntype = i;entemp.next = null;if(qlength(qi) = 1)orderinser(ev, entemp);return ok;圖3 測試customerarrived函數(shù)四、系統(tǒng)測試圖4控制函數(shù)圖5 測試函數(shù)圖6 測試函數(shù)圖7 測試函數(shù)圖8 測試結果五、總結實驗結果分析利用隨機產生的種子進行事件的模擬,即到達時間和辦理業(yè)務的時間都是隨機產生。如果事件尚未到達下班時間,則將其插入到空隊列或者是人數(shù)(元素)最少的隊列,通過檢驗,算出在不同的服務窗口數(shù)下的等待時間以及服務時間,基本
7、上實現(xiàn)了銀行事件的模擬。實驗心得體會數(shù)據(jù)結構是一門理論性較強且抽象的課程,經(jīng)過一周的數(shù)據(jù)結構課程設計,至今我仍感受頗深,從選題到定稿,從理論到實踐,在短短的一周時間里,雖然時間比較緊,但我學到了很多以前不知道的東西,同時不僅復習和鞏固了以前所學過的知識,而且看到了和學到了很多在書本上所沒有學到過的知識,使我懂得了理論必須和實踐永遠的結合起來,才能有質的飛躍,從而提高自己的實際動手能力和獨立思考的能力。在設計的過程中遇到過很多問題,但我一直堅持著,這畢竟第一次做的,難免會遇到過各種各樣的問題,同時在設計的過程中發(fā)現(xiàn)了自己的不足之處,對以前所學過的知識理解得不夠深刻,掌握得不夠牢固,現(xiàn)在覺得一定要
8、把以前所學過的知識重新溫故。雖然我的算法不夠完好,還有許多問題,但我一定會調試成功的。六、附件(代碼、部分圖表)/* experiment of datastructure file* copyright (c) 2014-2015, htucairangdunzhu. all rights reserved.*purpose:* 實現(xiàn)了模擬銀行的程序設計,并且包含每一個客戶離開時間及統(tǒng)計,以及* 窗口排隊的可視化模擬.運行測試通過.* public*2014.12才讓頓珠于隴橋三號樓215宿舍*/#define ok 1#define true 1#define false 0#define
9、 error 0#define infeasible -1#define overflow -2typedefint status;/-銀行排隊模擬/事件和事件表typedefstructqcueventintoccurtime;intntype;structqcuevent *next;qcuevent, *eventlist;/窗口前隊列元素typedefstructqcuelemintarrivaltime;int duration;structqcuelem *next;qcuelem,*qeptr;/窗口指針typedefstruct qeptr front;qeptr rear;q
10、customerp,*qcupp;/主要操作函數(shù)status openforday(eventlist&ev, qcuevent en, qcupp&q);/開門status customerarrived(eventlist&ev, qcupp&q, qcueventen);/顧客到達status customerdeparture(eventlist&ev, qcupp&q, qcuevent en);/顧客離開voidcloseforday();/基本操作函數(shù)status orderinser(eventlist&ev, qcuevent en);/按時間順序插入事件到事件表intqle
11、ngth(qcustomerpqn);/求窗口隊列長度intmincuqueue(qcupp q);/求隊最短的窗口status delfirstevent(eventlist&ev);/刪除事件表中的第一個事件status initcuqueue(qcustomerp&qn);/初始化窗口隊列status encuqueue(qcustomerp&qn,qeptr q);/進入隊列status decuqueue(qcustomerp&qn,qcuelem&q);/刪除隊列中的元素status getqhead(qcustomerpqn,qcuelem&q);/獲得隊列中的第一個元素stat
12、us destoryqueue(qcustomerpqn);/銷毀隊列void ptint_qstatus(qcustomerpqcu);/打印隊列長度voidbank_simulationfunc();void test(char str);#include stdio.h#include stdlib.h#include time.hint i=0,e=0,counter=0;inttotaltime=0,customernum=0;/累計客戶逗留時間,客戶數(shù)intclosetime;/關門時間intwindowsnum = 0;/主函數(shù)void main() eventlistev; /
13、 事件表qcuevent en; qcuppqcu = null;openforday(ev, en, qcu);while (ev-next)en.ntype = ev-next-ntype;en.occurtime = ev-next-occurtime;delfirstevent(ev);if (en.ntype = 0)customerarrived(ev, qcu, en);elsecustomerdeparture(ev, qcu, en);ptint_qstatus(qcu);closeforday();/主要功能子函數(shù)status openforday(eventlist&ev
14、, qcuevent en, qcupp&q)int temp = 0;printf(請輸入隨機數(shù)種子(或輸入0使用隨機種子):);scanf(%d,&temp);if (temp=0) srand(unsigned)time(null);elsesrand(temp);printf(請輸入營業(yè)時間(單位:分鐘):);scanf(%d,&temp);closetime = temp;totaltime = 0;customernum = 0;en.occurtime = 0;en.ntype = 0;en.next = null;ev = (eventlist) malloc(sizeof(q
15、cuevent);ev-next = null;orderinser(ev, en);printf(請輸入辦理業(yè)務的窗口數(shù)(至少1個):);scanf(%d,&windowsnum);q = (qcustomerp *) malloc(windowsnum+1)*sizeof(qcustomerp);for (int i=1;i=windowsnum;i+)initcuqueue(qi);return ok;status customerarrived(eventlist&ev, qcupp&q, qcuevent en)test(顧客到達處理);customernum +;/ 產生隨機數(shù)/s
16、rand(54);intdurtime = rand()%30+1;intintertime = rand()%5+1; / 插入到達事件表qcuevententemp;int t = en.occurtime + intertime;entemp.occurtime = t;entemp.ntype = 0;entemp.next = null;if (t arrivaltime = en.occurtime;q-duration = durtime;q-next = null;int i = mincuqueue(q);encuqueue(qi,q); / 插入離開事件entemp.occ
17、urtime = en.occurtime + durtime;entemp.ntype = i;entemp.next = null;if(qlength(qi) = 1)orderinser(ev, entemp);return ok;status customerdeparture(eventlist&ev, qcupp&q, qcuevent en)test(顧客離開處理);int i = en.ntype;printf(離開時間%dn,en.occurtime);if(en.occurtimeclosetime)destoryqueue(qi);elseqcuelem custome
18、r;decuqueue(qi,customer);/ 客戶逗留時間totaltime += en.occurtime - customer.arrivaltime;printf(總時間為%dn,totaltime);if (qi.front-next)getqhead(qi,customer);qcuevententemp;entemp.occurtime = en.occurtime + customer.duration;entemp.ntype = i;orderinser(ev, entemp);return ok;voidcloseforday()printf(*n);printf(
19、*n);printf(* 所有顧客業(yè)務辦理總時間:%d分鐘n, totaltime);printf(* 業(yè)務辦理顧客數(shù):%dn, customernum);printf(* 平均每人辦理時間:%fn,(float)totaltime/(float)customernum);printf(*n);printf(*n);/功能實現(xiàn)子函數(shù)status orderinser(eventlist&ev, qcuevent en)eventlistentemp,qtemp;entemp = (eventlist) malloc(sizeof(qcuevent);entemp-occurtime = en.
20、occurtime;entemp-ntype = en.ntype;entemp-next = null;if (!ev-next)ev-next = entemp;return ok;qtemp = ev;while(qtemp-next&qtemp-next-occurtimenext;entemp-next = qtemp-next;qtemp-next = entemp;return ok;intqlength(qcustomerpqn) qeptrqtemp;int i=0;qtemp = qn.front-next;while(qtemp)qtemp = qtemp-next;i+
21、;return i;intmincuqueue(qcupp q)inti,min;for (i=1,min=1;i=windowsnum;i+)min = qlength(qmin)next;ev-next = p-next;free(p);return ok;status initcuqueue(qcustomerp&qn)qn.front = (qeptr) malloc(sizeof(qcuelem);qn.front-next = null;qn.rear = qn.front;return ok;status encuqueue(qcustomerp&qn,qeptr q)qn.rear-next = q;qn.rear = q;
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國氟苯乙考粉數(shù)據(jù)監(jiān)測研究報告
- -教科版高中信息技術選修3教學設計-2.2.2 IP 地址的管理
- 2025至2030年中國板式輸送機數(shù)據(jù)監(jiān)測研究報告
- 第三單元課外古詩詞誦讀《晚春》教學設計-2023-2024學年統(tǒng)編版語文七年級下冊
- 浙教版信息技術五年級上冊《第1課 身邊的算法》教學設計
- 第二單元第一節(jié) 確定主題精搜索 教學設計 2024-2025學年川教版(2024)初中信息技術七年級上冊
- 第23課 教學設計-七年級上學期體育與健康
- 二零二五年度一手房購房稅費計算與繳納協(xié)議
- 二零二五年度校外住宿學生安全管理與責任認定合同
- 2025年度無社保的培訓生勞動合同
- 鋼結構防塵網(wǎng)拆除施工方案
- 2023年貴州省公務員錄用考試《行測》真題及答案解析
- AQ 6111-2023個體防護裝備安全管理規(guī)范知識培訓
- 水滸傳讀書分享會
- 柴油機維修施工方案
- GB/T 44744-2024糧食儲藏低溫儲糧技術規(guī)程
- 房地產市場報告 -【成都】【銳理】2024年10月丨房地產市場月報
- 《護理禮儀與人際溝通》第五章
- 《電工儀表與測量》課程教學大綱
- 危急值的考試題及答案
- 《算法設計與分析基礎》(Python語言描述) 課件 第1章 緒論
評論
0/150
提交評論