| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 856 人关注过本帖
标题:银行排队问题,求思路!!!
只看楼主 加入收藏
爱编聪聪
Rank: 2
等 级:论坛游民
帖 子:26
专家分:20
注 册:2013-9-16
结帖率:100%
收藏
已结贴  问题点数:16 回复次数:3 
银行排队问题,求思路!!!



         刚刚学完队列,想写一个银行排队的程序,但是不知道具体思路,最后要输出什么结果,急求指点!!!
2013-11-04 07:38
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:16 
靠,你输入什么就输出什么啊,问问题莫名其妙的。
具体思路不就是一个队列吗,再把书本看一遍,还不懂就在看一遍,

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-11-04 08:11
爱编聪聪
Rank: 2
等 级:论坛游民
帖 子:26
专家分:20
注 册:2013-9-16
收藏
得分:0 
回复 2楼 yuccn
为什么莫名其妙啊,你说的才莫名其妙呢,谁不知道输入什么就输出什么啊,我只是知道有人写关于银行排队程序,所以也想知道那个算法有什么功能,能实现什么功能,就算做题不也得知道“题目”是什么吗,你的理解能力我实在不敢恭维,还是你认为在这诋毁我问的问题可以显示你有多厉害啊,我是没有你厉害,我只不过是刚刚学完c,刚刚开始学数据结构而已,,,,你如果不屑于告诉我题目是什么,完全可以不用说,,,,,,,,
2013-11-04 10:05
卡殿
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-5-2
收藏
得分:0 
#include<iostream>
#include<stdlib.h>
#include<windows.h>
using namespace std;
const int maxsize=1000;
class seqqueue
{
public:
    char queue[maxsize];//将队列中的元素定义为数组型
    int front;          //队头指针
     int rear;           //队尾指针
    int len,totle_time;
    int changdu;
    void iniqueue();     //设置空队列
    void enqueue(char x);      //将x插入到队尾中,进队
    void dlqueue();            //将队列的队头元素删除,退队
    char gethead();             //取队头元素的值
    int empty();              //判队空
};
void seqqueue::iniqueue()         //设置空队列
{
    front=rear=maxsize-1;
}
void seqqueue::enqueue(char x)          //将x插入到队尾中,进队
{
    if((rear+1)%maxsize==front)
        cout<<"overflow"<<endl;
    else
    {
        rear=(rear+1)%maxsize;
        queue[rear]=x;
    }
}
void seqqueue::dlqueue()                //将队列的队头元素删除,退队
{
    if(rear==front)
        cout<<"underflow"<<endl;
    else
        front=(front+1)%maxsize;
}
char seqqueue::gethead()              //取队头元素的值
{
    if(front==rear)
    {
        cout<<"underflow"<<endl;
        return NULL;
    }
    else
        return queue[(front+1)%maxsize];
}
int seqqueue::empty()               //判队空
{
    if(front==rear)
        return 1;
    else
        return 0;
}
int prepare()
{
    int mintues;
    int i,x,n=1;   
    int min;
    int k=1;
    int w=0,totle_time=0;;
    seqqueue *p=new seqqueue[4];
    for(i=0;i<4;i++)
        p[i].iniqueue();  //四个窗口的初始化
    for(i=0;i<4;i++)      //随机产生四个窗口排队人数   
    {
        p[i].len=1+rand()%9;
        p[i].changdu=1;
        w+=p[i].len;
    }
    for(i=0;i<p[0].len;i++)        //一号窗口进队
    {
        p[0].enqueue(k);
        p[0].changdu++;
        k++;
    }
    k=1;
    for(i=0;i<p[1].len;i++)        //二号窗口进队
    {
        p[1].enqueue(k);
        p[1].changdu++;
        k++;
    }
    k=1;
    for(i=0;i<p[2].len;i++)        //三号窗口进队
    {
        p[2].enqueue(k);
        p[2].changdu++;
        k++;
    }
    k=1;
    for(i=0;i<p[3].len;i++)        //四号窗口进队
    {
        p[3].enqueue(k);
        p[3].changdu++;
        k++;
    }
    for(;;)
    {
        system("color 12");
        cout<<"***********************************"<<endl;
        cout<<"***********************************"<<endl;
        cout<<"***********************************"<<endl;
        cout<<"*********银行业务模拟系统**********"<<endl;
        cout<<"******   【1】取号            *****"<<endl;
        cout<<"******   【2】窗口查询        *****"<<endl;
        cout<<"******   【3】总窗口查询      *****"<<endl;
        cout<<"******   【4】客户平均逗留时间*****"<<endl;
        cout<<"******   【5】退出系统        *****"<<endl;
        cout<<"***********************************"<<endl;
        cout<<"***********************************"<<endl;
        cout<<"***********************************"<<endl;
        cout<<endl;
        cout<<"请选择:"<<endl;
        cin>>x;
        switch(x)
        {
        case 1:
            {
                system("cls");
                for(i=0;i<4;i++)      //随机产生四个窗口排队人数   
                {
                    p[i].len=1+rand()%10;
                    w+=p[i].len;
                }
                cout<<"亲,您是第"<<w+1<<"位顾客哦!"<<endl;
                cout<<endl;
                cout<<"3秒后,返回主菜单……"<<endl;
                cout<<endl;
                Sleep(3000);
                break;
            }
        case 2:
            {
                system("cls");
                int m;
                cout<<"请输入您要查询的窗口号(1-4):"<<endl;
                cin>>m;
                while(m<1||m>4)
                {
                    cout<<"窗口输入错误,请重新输入:";
                    cin>>m;        
                }
                cout<<m<<"号窗口有"<<p[m-1].changdu<<"位顾客。"<<endl;
                cout<<endl;
                cout<<"5秒后,返回主菜单……"<<endl;
                Sleep(5000);
                cout<<endl;
                break;
            }
        case 3:
            {
                system("cls");
                for(i=0;i<4;i++)      //计算最少人数
                {
                   min=p[0].changdu;
                     for(i=1;i!=4;i++)
                     {
                       min=(min<p[i].changdu)?min:p[i].changdu;
                     }
                }
                for(i=0;i<4;i++)      //计算最少人数的窗口  i+1
                {
                    if(p[i].changdu==min)
                    {
                        i=i++;
                        break;
                    }
                }
                for(;;)
                {
                    int x,totletime=0;      
                    cout<<"**********************"<<endl;
                    cout<<"【1】进入窗口动态浏览"<<endl;
                    cout<<"【2】退出窗口动态浏览"<<endl;
                    cout<<"**********************"<<endl;
                    cout<<endl;
                    cout<<"请选择:";
                    cin>>x;
                    switch(x)
                    {
                    case 1:
                        {
                         system("cls");
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<"所以,亲,你可以排在"<<i<<"号窗口哦!"<<endl;
                         cout<<"预计您只要稍等"<<min*(1+rand()%5)<<"分钟,就到您了!"<<endl;
                         mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                         mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }     
                        
                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }

                                                  mintues=1+rand()%6;
                         totletime+=mintues;
                         Sleep((mintues*1000));
                         system("cls");
                         if(mintues<5&&mintues>2)                             
                         {
                             p[0].dlqueue();
                             p[0].changdu--;
                             cout<<"1号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<3)                             
                         {
                             p[1].dlqueue();
                             p[1].changdu--;
                             cout<<"2号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6)                             
                         {
                             p[2].dlqueue();
                             p[2].changdu--;
                             cout<<"3号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         if(mintues<6&&mintues>3)                             
                         {
                             p[3].dlqueue();
                             p[3].changdu--;
                             cout<<"4号窗口一位顾客完成业务,请下一位顾客上前办理业务!"<<endl;
                         }
                         cout<<endl;
                         cout<<"1号窗口有"<<p[0].changdu<<"位顾客。"<<endl;
                         cout<<"2号窗口有"<<p[1].changdu<<"位顾客。"<<endl;
                         cout<<"3号窗口有"<<p[2].changdu<<"位顾客。"<<endl;
                         cout<<"4号窗口有"<<p[3].changdu<<"位顾客。"<<endl;
                         cout<<endl;
                         if((p[0].changdu<=0)||(p[1].changdu<=0)||(p[2].changdu<=0)||(p[3].changdu<=0))
                         {
                             cout<<w+1<<"号,请上前进行业务办理!"<<endl;
                             break;
                         }
                         break;
                        }
                    case 2:
                        return 0;
                        break;
                    }
                }
                cout<<endl;
                cout<<"5秒后,返回主菜单……"<<endl;
                cout<<endl;
                Sleep(5000);
                break;
            }
        case 4:
            {
                system("cls");
                int p;
                p=100+rand()%200;
                cout<<"银行大概一天办理业务的客户数:";
                cout<<p<<"人"<<endl;
                cout<<"每个客户平均逗留的时间:";
                cout<<totle_time<<"分钟"<<endl;
                cout<<endl;
                break;


            }
        case 5:
            {
                return 0;
            }
        }
    }


}
void main()
{
    prepare();
}
2014-05-26 13:44
快速回复:银行排队问题,求思路!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019690 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved