数据结构-银行排队问题

上传人:夏** 文档编号:565039141 上传时间:2023-06-22 格式:DOC 页数:25 大小:469.50KB
返回 下载 相关 举报
数据结构-银行排队问题_第1页
第1页 / 共25页
数据结构-银行排队问题_第2页
第2页 / 共25页
数据结构-银行排队问题_第3页
第3页 / 共25页
数据结构-银行排队问题_第4页
第4页 / 共25页
数据结构-银行排队问题_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《数据结构-银行排队问题》由会员分享,可在线阅读,更多相关《数据结构-银行排队问题(25页珍藏版)》请在金锄头文库上搜索。

1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-date数据结构-银行排队问题/*/*某银行营业厅共有6个营业窗口,设有排队系统广播叫号,该银行的业务分为公积金、银行卡、理财卡等三种。公积金业务指定1号窗口,银行卡业务指定2、3、4号窗口,理财卡业务指定5、6号窗口。但如果5、6号窗口全忙,而2、3、4号窗口有空闲时,理财卡业务也可以在空闲的2、3、4号窗口之一办理。客户领号、业务完成可以作为输入信息,要求可以随时显示6个

2、营业窗口的状态。*/1. 源程序#include#include#define MAXSIZE 10;typedef struct Peostruct Peo *next;PeoNode;typedef struct PeoNode *head; PeoNode *rear; int length;LQueueBank; LQueueBank InitQueue(LQueueBank *W)W-length = 0; W-head = (PeoNode *)malloc(sizeof(PeoNode); if(W-head!=NULL) W-head-next=NULL; W-rear=W-h

3、ead; return *W;void InLCK(LQueueBank *A, LQueueBank *B,LQueueBank *C)if(B-length length+;printf(办理中n);else if(C-length length+;printf(办理中n);elseprintf(请等待n);A-length+;A-rear = A-rear-next;void InGJJ(LQueueBank *A, LQueueBank *B)if(B-length length+;printf(办理中n);elseprintf(请等待n);A-length+;A-rear = A-r

4、ear-next;void InYHK(LQueueBank *A, LQueueBank *B)if(B-length length+;printf(办理中n);elseprintf(请等待n);A-length+;A-rear = A-rear-next; void Leave(LQueueBank *A, LQueueBank *B,LQueueBank *C,LQueueBank *D,LQueueBank *E,LQueueBank *F)printf(请输入离开用户所在窗口n);int yw;scanf(%d,&yw);switch(yw) case 1: A-rear = A-h

5、ead;A-length-;if(D-length 0)printf(请等待办理公积金的第一位用户来窗口1办理n);InGJJ(D,A);break;case 2:case 3:case 4: B-rear = B-head-next-next;B-length-;if(E-length 0) printf(请等待办理银行卡的第一位用户来窗口%d办理n,yw); InYHK(E,B); else if (F-length 0) printf(请等待办理理财卡的第一位用户来窗口%d办理n,yw);InLCK(F,C,B);break; case 5: case 6:C-length-; C-re

6、ar = C-head-next;if(F-length 0)InLCK(F,C,B); printf(请等待办理理财卡的第一位用户来窗口%d办理n,yw);break;default: printf(输入有误,请重试!n); void PRINT(LQueueBank *A, LQueueBank *B,LQueueBank *C) if(A-length = 0) printf(1号窗口空闲中n); else printf(1号窗口忙碌中n); if(B-length = 0) printf(2号窗口空闲中n3号窗口空闲中n4号窗口空闲中n); else if(B-length = 1)

7、printf(2号窗口忙碌中n3号窗口空闲中n4号窗口空闲中n); else if(B-length = 2) printf(2号窗口忙碌中n3号窗口忙碌中n4号窗口空闲中n); else if(B-length = 3) printf(2号窗口忙碌中n3号窗口忙碌中n4号窗口忙碌中n); if(C-length = 0) printf(5号窗口空闲中n6号窗口空闲中n); else if(C-length = 1) printf(5号窗口忙碌中n6号窗口空闲中n); else if(C-length = 2) printf(5号窗口忙碌中n6号窗口忙碌中n); void main() LQu

8、eueBank Wait1,Wait2,Wait3,Busy1,Busy2,Busy3; /1:公积金 2:银行卡 3:理财卡 Wait1 = InitQueue(&Wait1);Wait2 = InitQueue(&Wait2);Wait3 = InitQueue(&Wait3);Busy1 = InitQueue(&Busy1);Busy2 = InitQueue(&Busy2);Busy3 = InitQueue(&Busy3);int ch = 0; while(1) printf(-n); printf(1. 办理业务 ); printf(2. 完成离开 ); printf(3. 退

9、出 ); printf(0. 打印当前窗口状态n); while(1) scanf(%d,&ch); if(ch=0&ch=3) break; else printf(n输入有误,请重试!); switch(ch) case 0:PRINT(&Busy1,&Busy2,&Busy3);break; case 1: printf(请输入业务种类1/2/3n); printf(1. 公积金 2. 银行卡 3. 理财卡n); int yw1; scanf(%d,&yw1); switch(yw1) case 1: InGJJ(&Wait1,&Busy1);break; case 2: InYHK(&Wait2,&Busy2);break; case 3: InLCK(&Wait3,&Busy3,&Busy2);break; default: printf(输入有误,请重试!n); break; case 2: Leave(&Busy1,&Busy2,&Busy3,&Wait1,&Wait2,&Wait3); break; case 3:exit(0); default: break; 2.运行窗口截图:-

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号