| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1220 人关注过本帖
标题:小晒一下前几天关于银行排队问题的程序
只看楼主 加入收藏
小小小火柴
Rank: 5Rank: 5
来 自:江西赣州
等 级:职业侠客
威 望:3
帖 子:141
专家分:337
注 册:2012-9-28
结帖率:90.91%
收藏
 问题点数:0 回复次数:13 
小晒一下前几天关于银行排队问题的程序
大家一起学习!

程序后面动态窗口是利用system("cls")和Sleep()函数刷出来的!
自己写的,绝对原创!
请各位注意版权问题!
谢谢!

题目,请看我前几篇文章!



#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();
}
搜索更多相关主题的帖子: include public system 
2013-01-07 22:47
小小小火柴
Rank: 5Rank: 5
来 自:江西赣州
等 级:职业侠客
威 望:3
帖 子:141
专家分:337
注 册:2012-9-28
收藏
得分:0 
  哈哈!

   好好学习!
2013-01-07 22:47
crystall
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:7
帖 子:184
专家分:809
注 册:2012-12-1
收藏
得分:0 
程序代码:
    char queue[maxsize];
    int front;   
    int rear;       
    int len,totle_time;
    int changdu; //请问这个翻译后的意思是 长度 吗? 如果是,建议命名用简短的单词,养个好习惯
    void iniqueue();         
    void enqueue(char x);     
    void dlqueue();           
    char gethead();           
    int empty();              


[ 本帖最后由 crystall 于 2013-1-8 10:28 编辑 ]
2013-01-08 10:26
小小小火柴
Rank: 5Rank: 5
来 自:江西赣州
等 级:职业侠客
威 望:3
帖 子:141
专家分:337
注 册:2012-9-28
收藏
得分:0 
回复 3楼 crystall
    因为我这个表示这个队列的长度,一个客户进队,长度就++,一个客户出队就--,我当时欠缺考虑了,应该用个q_long之类的表示!

   好好学习!
2013-01-08 11:19
cl875821804
Rank: 2
等 级:论坛游民
帖 子:25
专家分:10
注 册:2012-11-24
收藏
得分:0 
建议楼主发个代码帖

just do it
2013-01-08 11:38
qunxingw
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:24
帖 子:1676
专家分:7295
注 册:2011-6-30
收藏
得分:0 
恭喜你,祝愿版本逐步优化升级。

www.qunxingw.wang
2013-01-08 11:58
yaobao
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:4
帖 子:1854
专家分:4121
注 册:2012-10-25
收藏
得分:0 
恭喜恭喜

认认真真的学习,踏踏实实的走路:戒骄戒躁!!!
2013-01-10 10:17
小小小火柴
Rank: 5Rank: 5
来 自:江西赣州
等 级:职业侠客
威 望:3
帖 子:141
专家分:337
注 册:2012-9-28
收藏
得分: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();
}

   好好学习!
2013-01-11 17:51
小小小火柴
Rank: 5Rank: 5
来 自:江西赣州
等 级:职业侠客
威 望:3
帖 子:141
专家分:337
注 册:2012-9-28
收藏
得分:0 
/*
课程设计题八 银行业务活动的模拟
任务:假设某银行有4个窗口对外接待客户,从早晨银行开门起不断有客户进入银行,
由于每个窗口在某个时刻只能接待一个客户。因此在客户人数众多时需要在每个窗口前顺次排队,
对于刚进入银行的客户。如果某个窗口的业务员正空闲,则可上前输业务。
反之,若个窗口均有客户所占,他便会排在为数最少的队伍后面。
编制一个程序模拟银行的这种业务活动并计算一天中客户在银行的平均逗留时间。
功能要求:
1).实现数据的输入;
2).各个窗口数据的访问和输出;
3)当前窗口的人员分布情况动态显示。
界面要求:有合理的提示,每个功能可以设立菜单,根据提示,可以完成相关的功能要求。
存储结构:学生自己根据系统功能要求自己设计。请在最后的上交资料中指明你用到的存储结构;
测试数据:要求使用1、全部合法数据;2、整体非法数据;3、局部非法数据。进行程序测试,以保证程序的稳定。
*/
#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:
                        {
                         int m=0;
                         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;

                         while(!m)
                         {
                         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;
                             m=1;
                             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<<"34分钟"<<endl;
                cout<<endl;
                break;


            }
        case 5:
            {
                return 0;
            }
        }
    }


}
void main()
{
    prepare();
}

   好好学习!
2013-01-11 17:52
xinglinzhang
Rank: 1
等 级:新手上路
帖 子:5
专家分:2
注 册:2013-1-14
收藏
得分:0 
强人啊,这么长怎么写的?
2013-01-14 17:20
快速回复:小晒一下前几天关于银行排队问题的程序
数据加载中...
 
   



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

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