/*某银行营业厅共有6个营业窗口,设有排队系统广播叫号,该银行的业务分为公积金、银行卡、理财卡等三种。公积金业务指定1号窗口,银行卡业务指定2、3、4号窗口,理财卡业务指定5、6号窗口。但如果5、6号窗口全忙,而2、3、4号窗口有空闲时,理财卡业务也可以在空闲的2、3、4号窗口之一办理。客户领号、业务完成可以作为输入信息,要求可以随时显示6个营业窗口的状态。*/1.源程序#includestdio.h#includestdlib.h#defineMAXSIZE10;typedefstructPeo{structPeo*next;}PeoNode;typedefstruct{PeoNode*head;PeoNode*rear;intlength;}LQueueBank;LQueueBankInitQueue(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;}voidInLCK(LQueueBank*A,LQueueBank*B,LQueueBank*C){if(B-length2){B-length++;printf(办理中\n);}elseif(C-length3){C-length++;printf(办理中\n);}else{printf(请等待\n);A-length++;A-rear=A-rear-next;}}voidInGJJ(LQueueBank*A,LQueueBank*B){if(B-length1){B-length++;printf(办理中\n);}else{printf(请等待\n);A-length++;A-rear=A-rear-next;}}voidInYHK(LQueueBank*A,LQueueBank*B){if(B-length3){B-length++;printf(办理中\n);}else{printf(请等待\n);A-length++;A-rear=A-rear-next;}}voidLeave(LQueueBank*A,LQueueBank*B,LQueueBank*C,LQueueBank*D,LQueueBank*E,LQueueBank*F){printf(请输入离开用户所在窗口\n);intyw;scanf(%d,&yw);switch(yw){case1:{A-rear=A-head;A-length--;if(D-length0){printf(请等待办理公积金的第一位用户来窗口1办理\n);InGJJ(D,A);}break;}case2:case3:case4:{B-rear=B-head-next-next;B-length--;if(E-length0){printf(请等待办理银行卡的第一位用户来窗口%d办理\n,yw);InYHK(E,B);}elseif(F-length0){printf(请等待办理理财卡的第一位用户来窗口%d办理\n,yw);InLCK(F,C,B);}break;}case5:case6:{C-length--;C-rear=C-head-next;if(F-length0)InLCK(F,C,B);printf(请等待办理理财卡的第一位用户来窗口%d办理\n,yw);break;}default:printf(输入有误,请重试!\n);}}voidPRINT(LQueueBank*A,LQueueBank*B,LQueueBank*C){if(A-length==0)printf(1号窗口空闲中\n);elseprintf(1号窗口忙碌中\n);if(B-length==0)printf(2号窗口空闲中\n3号窗口空闲中\n4号窗口空闲中\n);elseif(B-length==1)printf(2号窗口忙碌中\n3号窗口空闲中\n4号窗口空闲中\n);elseif(B-length==2)printf(2号窗口忙碌中\n3号窗口忙碌中\n4号窗口空闲中\n);elseif(B-length==3)printf(2号窗口忙碌中\n3号窗口忙碌中\n4号窗口忙碌中\n);if(C-length==0)printf(5号窗口空闲中\n6号窗口空闲中\n);elseif(C-length==1)printf(5号窗口忙碌中\n6号窗口空闲中\n);elseif(C-length==2)printf(5号窗口忙碌中\n6号窗口忙碌中\n);}voidmain(){LQueueBankWait1,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);intch=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;elseprintf(\n输入有误,请重试!);}switch(ch){case0:{PRINT(&Busy1,&Busy2,&Busy3);break;}case1:{printf(请输入业务种类1/2/3\n);printf(1.公积金2.银行卡3.理财卡\n);intyw1;scanf(%d,&yw1);switch(yw1){case1:{InGJJ(&Wait1,&Busy1);break;}case2:{InYHK(&Wait2,&Busy2);break;}case3:{InLCK(&Wait3,&Busy3,&Busy2);break;}default:printf(输入有误,请重试!\n);}break;}case2:{Leave(&Busy1,&Busy2,&Busy3,&Wait1,&Wait2,&Wait3);break;}case3:exit(0);default:break;}}}2.运行窗口截图: