数据结构-银行排队问题_第1页
数据结构-银行排队问题_第2页
数据结构-银行排队问题_第3页
数据结构-银行排队问题_第4页
数据结构-银行排队问题_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、/*某银行营业厅共有6个营业窗口,设有排队系统广播叫号,该银行的业务分为公积金、银行卡、理财卡等三种。公积金业务指定1号窗口,银行卡业务指定2、3、4号窗口,理财卡业务指定5、6号窗口。但如果5、6号窗口全忙,而2、3、4号窗口有空闲时,理财卡业务也可以在空闲的2、3、4号窗口之一办理。客户领号、业务完成可以作为输入信息,要求可以随时显示6个营业窗口的状态。*/1. 源程序#include#include#define MAXSIZE 10;typedef struct Peostruct Peo *next;PeoNode;typedef struct PeoNode *head; PeoN

2、ode *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-head; return *W;void InLCK(LQueueBank *A, LQueueBank *B,LQueueBank *C)if(B-length length+;printf(办理中n);else if(C-length length+;p

3、rintf(办理中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-rear-next;void InYHK(LQueueBank *A, LQueueBank *B)if(B-length length+;printf(办理中n);elseprintf(请等待n);A-length+;A-rear = A-rear-nex

4、t; 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-head;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-len

5、gth-;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-rear = C-head-next;if(F-length 0)InLCK(F,C,B); printf(请等待办理理财卡的第一位用户来窗口%d办理n,yw);break;default: printf(输入有误,请重试!n); void PRINT(LQu

6、eueBank *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) printf(2号窗口忙碌中n3号窗口空闲中n4号窗口空闲中n); else if(B-length = 2) printf(2号窗口忙碌中n3号窗口忙碌中n4号窗口空闲中n); else if(B-length = 3) printf(2号窗口忙碌中n3

7、号窗口忙碌中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() LQueueBank Wait1,Wait2,Wait3,Busy1,Busy2,Busy3; /1:公积金 2:银行卡 3:理财卡 Wait1 = InitQueue(&Wait1);Wait2 = InitQueue(&Wait2);Wait3 = Init

8、Queue(&Wait3);Busy1 = InitQueue(&Busy1);Busy2 = InitQueue(&Busy2);Busy3 = InitQueue(&Busy3);int ch = 0; while(1) printf(-n); printf(1. 办理业务 ); printf(2. 完成离开 ); printf(3. 退出 ); 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; defa

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论