#include <cstdio>
#include <queue>
using namespace std;
queue<int> w[8],z1,z2,z3;//z 记录哪些窗口为空闲,w 记录窗口排队人员
int main()
{
z1.push(1);
z2.push(2);z2.push(3);z2.push(4);
z3.push(5);z3.push(6);//初始化,所有窗口均为空闲,加入 z 队列
printf("请选择功能,办理业务为 1,业务完成为 2,显示窗口状态为 3");
int n;
int step=1;
while(~scanf("%d",&n)){
if(n==1) {
printf("请选择要办理的业务模式,1 为公积金,2 为银行业务,3 为理财卡业
务");
int t;
scanf("%d",&t);
if(t==1){
if(!z1.empty()){
z1.pop();
w[1].push(step);
printf("请%d 号用户到 1 号窗口办理业务",step);
step++;
}//窗口为空的话直接取号去办理业务
else {
w[1].push(step++);
printf("请%d 号用户稍作等候",step-1);
}//窗口非空的话请人稍等
}
else if(t==2){
if(!z2.empty()){
int temp = z2.front();
z2.pop();
w[temp].push(step);
printf("请%d 号用户到%d 号窗口办理业务",step,temp);
step++;
}
else {
int bb=w[2].size(),bm = 2;
if(w[3].size()<bb) {bb = w[3].size();bm = 3;}
if(w[4].size()<bb) {bb = w[4].size();bm =4;}
w[bm].push(step++);
printf("请%d 号用户稍作等候",step-1);
评论0