首页 > 其他分享 >数据结构实训_银行管理系统

数据结构实训_银行管理系统

时间:2023-05-09 11:12:07浏览次数:45  
标签:node NULL 管理系统 money vip 实训 time front 数据结构

记录下自己寒假写的千行代码,虽然千行,但是质量不高,但是好歹自己写的,记录下嘿嘿

#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
//----------------------------------------顾客信息-----------------------------------------
struct node
{
    int type;//存钱为1,取钱为0
    int win;//第几个窗口
    int num;//序列号
    int vip;//是否是vip
    int money;//办理金额,正数为存钱,负数为取钱
    int start_time;//开始时间
    int leave_time;//离开时间
    node* next;
} customer;
//----------------------------------队列结构体以及函数---------------------------------------
struct Queue
{
    node* front;//队头
    node* end;//队尾
    int size;
}*Q[10], *Q2, *Q_en, *Q_vip1, *Q_vip2; //第一队列,第二队列,时间(开始,结束)队列
//push操作
void Push(Queue* &q, node* e)
{
    if(e == NULL) return;
    if(q -> front == NULL)
    {
        q -> size = 1;
        q -> front = e;
        q -> end = e;
    }
    else
    {
        q -> size ++;
        q -> end -> next = e;
        q -> end = q -> end -> next;
    }
}
//empty操作
void Empty(Queue* &q)
{
    node *a, *b;
    a = new node;
    b = new node;
    a = q->front;
    q -> size = 0;
    if(q -> front == NULL && q -> end == NULL)
    {
        return;
    }
    while(a != NULL)
    {
        b = a -> next;
        delete(a);
        a = NULL;
        a = b;
    }
}
//pop操作
void Pop(Queue *&q)
{//后面会与size函数一起用
    node *e;
    e = q ->front;
    if(q -> front == NULL)
    {
        //没有元素,size = 0,不会删除
        return;
    }
    else if(q -> front -> next == NULL)
    {
        //就一个元素
        q -> size = 0;
        q -> front = q -> end = NULL;
    }
    else
    {
        //有好多元素
        q -> size --;
        q -> front = q -> front -> next;
    }
    delete(e);
    e = NULL;
}
//得到队首元素
node *front(Queue* &q)
{
    return q -> front;
}
//得到队列长度
int size(Queue* &q)
{
    int ans = max(0, q -> size);
    return ans;
}
//队列初始化操作
void inti()
{
    for(int i = 0; i < 8; i ++)
    {
        Q[i] = new Queue;
    }
    Q2 = new Queue;
    Q_en = new Queue;
    Q_vip1 = new Queue;
    Q_vip2 = new Queue;
    for(int i = 0; i < 8; i ++)
    {
        if(Q[i] == NULL) return;
    }
    if(Q2 == NULL || Q_en == NULL || Q_vip1 == NULL ||Q_vip2 == NULL)
    {
        return ;
    }
    for(int i = 0; i < 8; i ++)
    {
        Q[i] -> size = 0;
        Q[i] -> front = NULL;
        Q[i] -> end = NULL;
    }
    Q2 -> size = 0;
    Q2 -> front = NULL;
    Q2 -> end = NULL;
    Q_en -> size = 0;
    Q_en -> front = NULL;
    Q_en -> end = NULL;
    Q_vip1 -> size = 0;
    Q_vip1 -> front = NULL;
    Q_vip1 -> end = NULL;
    Q_vip2 -> size = 0;
    Q_vip2 -> front = NULL;
    Q_vip2 -> end = NULL;
}
//------------------------------------------全局变量定义-------------------------------------------
int total_money;//设定银行总钱数
int total_time;//客户逗留总时间
int opentime;//设定银行开门时间
int closetime;//设定银行关门时间
int nowtime = 0;//设定当前时间
int dealtime[10] = {0};//交易时间
int flag[10] = {0};//窗口开否(nope0, yep1)
int flag_vip = 0;//vip窗口开否(nope0, yep1)
int dealtime_vip = 0;//vip交易时间
int starttime;//用户到达时间
int ArriveMaxTime;//最大到达时间
int ArriveMinTime;//最小到达时间
int DealMaxTime;//最大交易时间
int DealMinTime;//最小交易时间
int sum_consumer = 0;//客户总数
int num_consumer = 1;//客户号码
int MaxMoney;//交易额上限
//------------------------------------------小函数区域--------------------------------------
//到达后存储在队列里函数
void arrive(int ww)
{
    node *a, *b;
    a = new node;
    b = new node;
    if(a == NULL || b == NULL) return;
    int num = (rand()%(2 * MaxMoney) - MaxMoney);
    a -> win = ww;
    b -> win = ww;
    a -> money = num;
    b -> money = num;
    a -> vip = 0;
    b -> vip = 0;
    a -> start_time = nowtime;
    b -> start_time = nowtime;
    a -> num = num_consumer;
    b -> num = num_consumer;
    a -> next = NULL;
    b -> next = NULL;
    Push(Q[ww], a);
    b -> type = 0;
    Push(Q_en, b);
    num_consumer ++;
}
void vip_arrive()
{
    node *a, *b;
    a = new node;
    b = new node;
    if(a == NULL || b == NULL) return;
    int num = (rand()%(2 * MaxMoney) - MaxMoney);
    a -> money = num;
    b -> money = num;
    a -> vip = 1;
    b -> vip = 1;
    a -> start_time = nowtime;
    b -> start_time = nowtime;
    a -> num = num_consumer;
    b -> num = num_consumer;
    a -> next = NULL;
    b -> next = NULL;
    Push(Q_vip1, a);
    b -> type = 0;
    Push(Q_en, b);
    num_consumer ++;
}
//搜索函数
node *search(Queue* &q)
{
    node *a, *b;
    a = new node;
    b = new node;
    a = q -> front;
    while(q -> front != NULL)
    {
        if(abs(q -> front -> money) <= total_money)
        {
            //可以取钱啦
            if(q -> front == q -> end)
            {
                b = q -> front;
                q -> front = NULL;
                q -> end = NULL;
                return b;
            }
            else
            {
                b = q -> front;
                q -> front = q -> front -> next;
                return b;
            }
        }
        else//不可以取钱,要把这个移到队列后面,然后再看看后边的可不可以
        {
            if(q -> front != q -> end)
            {
                q -> end -> next = q -> front;
                q -> end = q -> end -> next;
                q -> front = q -> end -> next;
                q -> end -> next = NULL;
            }
        }
        if(q -> front == a)
            return NULL;
    }
    return NULL;
}
//存钱
void in_money(int ww)
{
    node *a, *b;
    a = new node;
    b = new node;
    a = Q[ww]->front;
    total_money += a -> money;//存钱
    //离开事件
    b -> type = 1;
    b -> win = a -> win;
    b -> vip = a -> vip;
    b -> num = a -> num;
    b -> money = a -> money;
    int leave = rand() % (DealMaxTime - DealMinTime + 1) + DealMinTime;
    b -> leave_time = a -> start_time + leave;
    b -> next = NULL;
    Push(Q_en, b);//放入事件队列
    sum_consumer ++;//客户总数增加
    total_time += (b -> leave_time - a -> start_time);//总时间增加
    if(size(Q[ww])) Pop(Q[ww]);//让第一队列队首元素出队
    dealtime[ww] = b -> leave_time;//交易时间变更为此交易结束后的时间
    flag[ww] = 0;
    //搜索一下第二队列,看看有没有可以交易的
    node *c, *d;
    c = new node;
    d = new node;
    while((c = search(Q2)) != NULL)
    {
        d = new node;
        total_money += c -> money;
        d -> type = 1;
        d -> win = c -> win;
        d -> vip = c -> vip;
        d -> num = c -> num;
        d -> money = c -> money;
        d -> next = NULL;
        int left = rand() % (DealMaxTime - DealMinTime + 1) + DealMinTime;
        d -> leave_time = c -> start_time + left;
        Push(Q_en, d);
        dealtime[ww] = d -> leave_time;
        total_time += left;
        sum_consumer ++;
        delete(c);
        c = NULL;
    }
    flag[ww] = 0;
}
void vip_in_money()
{
    node *a, *b;
    a = new node;
    b = new node;
    a = Q_vip1->front;
    total_money += a -> money;//存钱
    //离开事件
    b -> type = 1;
    b -> vip = a -> vip;
    b -> num = a -> num;
    b -> money = a -> money;
    int leave = rand() % (DealMaxTime - DealMinTime + 1) + DealMinTime;
    b -> leave_time = a -> start_time + leave;
    b -> next = NULL;
    Push(Q_en, b);//放入事件队列
    sum_consumer ++;//客户总数增加
    total_time += (b -> leave_time - a -> start_time);//总时间增加
    if(size(Q_vip1)) Pop(Q_vip1);//让第一队列队首元素出队
    dealtime_vip = b -> leave_time;//交易时间变更为此交易结束后的时间
    flag_vip = 0;
    //搜索一下第二队列,看看有没有可以交易的
    node *c, *d;
    c = new node;
    d = new node;
    while((c = search(Q_vip2)) != NULL)
    {
        d = new node;
        total_money += c -> money;
        d -> type = 1;
        d -> vip = c -> vip;
        d -> num = c -> num;
        d -> money = c -> money;
        d -> next = NULL;
        int left = rand() % (DealMaxTime - DealMinTime + 1) + DealMinTime;
        d -> leave_time = c -> start_time + left;
        Push(Q_en, d);
        dealtime_vip = d -> leave_time;
        total_time += left;
        sum_consumer ++;
        delete(c);
        c = NULL;
    }
    flag_vip = 0;
}
//取钱
void out_money(int ww)
{
    node *a, *b;
    a = new node;
    b = new node;
    a = front(Q[ww]);
    if(abs(a -> money) > total_money)//不可以取款,放入第二队列等待
    {
        //第一队列pop,第二队列push
        b -> start_time = a -> start_time;
        b -> win = a -> win;
        b -> money = a -> money;
        b -> vip = a -> vip;
        b -> num = a -> num;
        b -> next = NULL;
        Push(Q2, b);
        if(size(Q[ww])) Pop(Q[ww]);
    }
    else
    {
        //可以取款
        total_money += a -> money;
        b -> type = 1;
        b -> win = a -> win;
        b -> vip = a -> vip;
        b -> money = a -> money;
        b -> num = a -> num;
        b -> next = NULL;
        int left = rand()%(DealMaxTime - DealMinTime + 1) + DealMinTime;
        b -> leave_time = a -> start_time + left;
        Push(Q_en, b);
        if(size(Q[ww])) Pop(Q[ww]);
        dealtime[ww] = b -> leave_time;
        total_time += left;
        sum_consumer ++;
        flag[ww] = 0;
    }
}
void vip_out_money()
{
    node *a, *b;
    a = new node;
    b = new node;
    a = front(Q_vip1);
    if(abs(a -> money) > total_money)//不可以取款,放入第二队列等待
    {
        //第一队列pop,第二队列push
        b -> start_time = a -> start_time;
        b -> money = a -> money;
        b -> vip = a -> vip;
        b -> num = a -> num;
        b -> next = NULL;
        Push(Q_vip2, b);
        if(size(Q_vip1)) Pop(Q_vip1);
    }
    else
    {
        //可以取款
        total_money += a -> money;
        b -> type = 1;
        b -> vip = a -> vip;
        b -> money = a -> money;
        b -> num = a -> num;
        b -> next = NULL;
        int left = rand()%(DealMaxTime - DealMinTime + 1) + DealMinTime;
        b -> leave_time = a -> start_time + left;
        Push(Q_en, b);
        if(size(Q_vip1)) Pop(Q_vip1);
        dealtime_vip = b -> leave_time;
        total_time += left;
        sum_consumer ++;
        flag_vip = 0;
    }
}
//加入时间转换器
bool check(string &s)
{
    if (s.size() > 5 || s.size() < 3)
        return false;
    if (s.size() < 5)
    {
        int op = -1;
        for (auto it : s)
        {
            op++;
            if (it == ':')
            {
                break;
            }
        }
        if (op == -1)
            return false;
        if (op == 0 || op > 3)
            return false;
        if (op == 1)
        {
            s.insert(s.begin(), '0');
            if (s.size() == 4)
                s.insert(s.begin() + 3, '0');
        }
        if (op == 2)
            s.insert(s.begin() + 3, '0');
    }
    if (s[0] < '0' || s[0] > '9')
        return false;
    if (s[1] < '0' || s[1] > '9')
        return false;
    if (s[2] != ':')
        return false;
    if (s[3] < '0' || s[3] > '9')
        return false;
    if (s[4] < '0' || s[4] > '9')
        return false;
    int a = (s[0] - '0') * 10 + (s[1] - '0');
    int b = (s[3] - '0') * 10 + (s[4] - '0');
    if (a < 0 || a > 23)
        return false;
    if (b < 0 || b > 59)
        return false;
    return true;
}
int hm_mm(string s)
{
    int a = (s[0] - '0') * 10 + (s[1] - '0');
    int b = (s[3] - '0') * 10 + (s[4] - '0');
    return a * 60 + b;
}
string mm_hm(int sum)
{
    string s = "";
    int a = sum / 60, b = sum % 60;
    if (a >= 0 && a <= 9)
    {
        s += '0';
        s += a + '0';
    }
    else
    {
        char aa = a/10 + '0';
        char ab = a%10 + '0';
        s += aa;
        s += ab;
    }
    s += ':';
    if (b >= 0 && b <= 9)
    {
        s += '0';
        s += b + '0';
    }
    else
    {
        char bb = b/10 + '0';
        char ba = b%10 + '0';
        s += bb;
        s += ba;
    }
    return s;
}
//------------------------------------------主函数-------------------------------------
int main()
{
    cout << "********************************************\n";
    cout << "********************************************\n";
    cout << "********************************************\n";
    cout << "**********   银行业务管理中心  ***************\n";
    cout << "**********     进入请输入1     ***************\n";
    cout << "**********     离开请输入0     ***************\n";
    cout << "********************************************\n";
    cout << "********************************************\n";
    cout << "********************************************\n";
    int op;
    cin >> op;
    while(op != 1 && op != 0)
    {
        puts("请输入1或者0,1代表进入模拟系统,0代表离开模拟系统");
        cin >> op;
    }
    if(op == 0)
    {
        puts("银行业务已结束");
        return 0;
    }
    //进入系统

    //---------------银行初始总金额----------------------
    puts("请输入银行初始金额:");
    cin >> total_money;
    while(total_money <= 0)
    {
        puts("银行初始金额不能小于等于零,请重新输入");
        cin >> total_money;
    }
    //---------------closetime------------------------
    puts("请输入银行开始营业时间:");
    string s_time;
    cin >> s_time;
    while (check(s_time) == false)
    {
        puts("时间输入应当以'数字:数字'形式输入,其中':'应该为英文标识,请重新输入");
        cin >> s_time;
    }
    opentime = hm_mm(s_time);
    puts("请输入银行结束营业时间:");
    string e_time;
    cin >> e_time;
    while (1)
    {
        if (check(e_time) == false)
        {
            puts("时间输入应当以'数字:数字'形式输入,其中':'应该为英文标识,请重新输入");
            cin >> e_time;
        }
        else
        {
            check(e_time);
            closetime = hm_mm(e_time);
            if (closetime < opentime)
            {
                puts("关门时间应该晚于开门时间,请重新输入");
                cin >> e_time;
            }
            else
                break;
        }
    }
    printf("营业时间为:");
    cout << closetime - opentime << endl;
    //--------------------到达时间上限--------------------------
    puts("请输入到达时间间隔上限:");
    cin >> ArriveMaxTime;
    while (ArriveMaxTime <= 0 || ArriveMaxTime > closetime - opentime)
    {
        puts("到达时间间隔上限不可以小于等于零,同时也不可以大于营业时间,请重新输入");
        cin >> ArriveMaxTime;
    }
    //--------------------到达时间下限--------------------------
    puts("请输入到达时间间隔下限:");
    cin >> ArriveMinTime;
    while (ArriveMinTime <= 0 || ArriveMinTime > ArriveMaxTime || ArriveMinTime > closetime - opentime)
    {
        puts("到达时间间隔下限不可以小于等于零,也不可以大于时间上限,还不可以大于营业时间,请重新输入");
        cin >> ArriveMinTime;
    }
    //---------------------最大处理时间----------------------------------------
    puts("请输入最大处理时间:");
    cin >> DealMaxTime;
    while (DealMaxTime <= 0 || DealMaxTime > closetime - opentime)
    {
        puts("最大处理时间不能小于等于零,且不能大于银行营业时间!请重新输入");
        scanf("%d", &DealMaxTime);
    }
    //----------------------最小处理时间---------------------------------------
    puts("请输入最小处理时间:");
    cin >> DealMinTime;
    while (DealMinTime <= 0 || DealMinTime > DealMaxTime || DealMinTime > closetime - opentime)
    {
        printf("最小处理时间不能小于等于零,不能大于最大处理时间,且不能大于银行营业时间!请重新输入\n");
        scanf("%d", &DealMinTime);
    }
    //---------------------交易额-----------------------------------------
    puts("请输入交易额:");
    cin >> MaxMoney;
    while(MaxMoney <= 0)
    {
        puts("交易额上限不可以小于等于零,请重新输入");
        cin >> MaxMoney;
    }
    puts("");
    //--------------------处理部分-----------------------------
    inti();
    starttime += rand() % (closetime - opentime + 1) + opentime;
    nowtime = starttime - 1;
    while(nowtime < closetime)//5000
    {
        nowtime ++;
        int v = rand()%2;//0 1 0 - n - 1
        if(v != 0)//普通队列
        {
            for(int i = 0; i < 5; i ++)
            {
                if(dealtime[i] <= nowtime)
                {
                    flag[i] = 1;
                    dealtime[i] = nowtime;
                }
            }
            if(starttime == nowtime)
            {
                int yep = INF;
                if(ArriveMaxTime <= 10 && DealMinTime >= 100)
                {//很忙碌,去找人少的排队
                    //没有在办理的窗口
                    for(int i = 0; i < 5; i ++)
                    {
                        if(flag[i] == 1)
                        {
                            yep = i;
                            break;
                        }
                    }
                    //哪个队人少排哪个
                    if(yep == INF)
                    {
                        for(int i = 0; i < 5; i ++)
                        {
                            int s = size(Q[i]);
                            if(s < yep) yep = s;
                        }
                    }
                }
                else yep = rand()%5;//随机窗口
                arrive(yep);
                starttime += rand() % (ArriveMaxTime - ArriveMinTime + 1) + ArriveMinTime;
            }
            for(int i = 0; i < 5; i ++)
            {
                if(flag[i] && Q[i] -> front != NULL)
                {
                    if(Q[i] -> front -> money >= 0)//存钱
                    {
                        int w = Q[i] -> front -> win;
                        in_money(w);
                    }
                    else //取钱
                    {
                        int w = Q[i] -> front -> win;
                        out_money(w);
                    }
                }
            }
        }
        else//vip队列
        {
            if(dealtime_vip <= nowtime)
            {
                flag_vip = 1;
                dealtime_vip = nowtime;
            }
            if(starttime == nowtime)
            {
                vip_arrive();
                starttime += rand() % (ArriveMaxTime - ArriveMinTime + 1) + ArriveMinTime;//2000000
            }
            if(flag_vip && Q_vip1 -> front != NULL)
            {
                if(Q_vip1 -> front -> money >= 0)//存钱
                {
                    vip_in_money();
                }
                else //取钱
                {
                    vip_out_money();
                }
            }
        }
    }
    //--------------------展示部分-----------------------------------------
    char consumer_id[10], thing_type[10], time[10], deal_money[10], consumer_win[10];
    strcpy(consumer_win, "窗口序号");
    strcpy(consumer_id, "客户序号");
    strcpy(thing_type, "事件类型");
    strcpy(time, "时间");
    strcpy(deal_money, "处理金额");
    printf("%10s%10s%10s%10s%10s\n", consumer_win, consumer_id, thing_type, time, deal_money);
    int success_in = 0, success_out = 0, need_in = 0, need_out = 0;
    for(int i = 0; i < 5; i ++)
    {
        while(Q[i] -> front != NULL)
        {
            if(Q[i]->front->money >= 0)
            {
                node *a, *b;
                a = new node;
                b = new node;
                a = Q[i]->front;
                total_money += a -> money;//存钱
                //离开事件
                b -> type = 1;
                b -> win = a -> win;
                b -> vip = a -> vip;
                b -> num = a -> num;
                b -> money = a -> money;
                b -> leave_time = closetime + 1;
                b -> next = NULL;
                Push(Q_en, b);//放入事件队列
                sum_consumer ++;//客户总数增加
                total_time += (b -> leave_time - a -> start_time);//总时间增加
                if(size(Q[i])) Pop(Q[i]);//让第一队列队首元素出队
            }
            else
            {
                node *a, *b;
                a = new node;
                b = new node;
                a = front(Q[i]);
                b -> type = 1;
                b -> vip = a -> vip;
                b -> money = a -> money;
                b -> num = a -> num;
                b -> next = NULL;
                b -> leave_time = closetime + 1;
                Push(Q_en, b);
                if(size(Q[i])) Pop(Q[i]);
                total_money += a -> money;
                total_time += (b -> leave_time - a -> start_time);
                sum_consumer ++;
            }
        }

    }
    while(Q_vip1 -> front != NULL)
    {
        if(Q_vip1->front->money >= 0)
        {
            node *a, *b;
            a = new node;
            b = new node;
            a = Q_vip1->front;
            total_money += a -> money;//存钱
            //离开事件
            b -> type = 1;
            b -> vip = a -> vip;
            b -> num = a -> num;
            b -> money = a -> money;
            b -> leave_time = closetime + 1;
            b -> next = NULL;
            Push(Q_en, b);//放入事件队列
            sum_consumer ++;//客户总数增加
            total_time += (b -> leave_time - a -> start_time);//总时间增加
            if(size(Q_vip1)) Pop(Q_vip1);//让第一队列队首元素出队
        }
        else
        {
            node *a, *b;
            a = new node;
            b = new node;
            a = front(Q_vip1);
            b -> type = 1;
            b -> vip = a -> vip;
            b -> money = a -> money;
            b -> num = a -> num;
            b -> next = NULL;
            b -> leave_time = closetime + 1;
            Push(Q_en, b);
            if(size(Q_vip1)) Pop(Q_vip1);
            total_money += a -> money;
            total_time += (b -> leave_time - a -> start_time);
            sum_consumer ++;
        }
    }
    while(Q2 -> front != NULL)
    {
        if(Q2->front->money >= 0)
        {
            node *a, *b;
            a = new node;
            b = new node;
            a = Q2->front;
            total_money += a -> money;//存钱
            //离开事件
            b -> type = 1;
            b -> win = a -> win;
            b -> vip = a -> vip;
            b -> num = a -> num;
            b -> money = a -> money;
            b -> leave_time = closetime + 1;
            b -> next = NULL;
            Push(Q_en, b);//放入事件队列
            sum_consumer ++;//客户总数增加
            total_time += (b -> leave_time - a -> start_time);//总时间增加
            if(size(Q2)) Pop(Q2);//让第一队列队首元素出队
        }
        else
        {
            node *a, *b;
            a = new node;
            b = new node;
            a = front(Q2);
            b -> type = 1;
            b -> win = a -> win;
            b -> vip = a -> vip;
            b -> money = a -> money;
            b -> num = a -> num;
            b -> next = NULL;
            b -> leave_time = closetime + 1;
            Push(Q_en, b);
            if(size(Q2)) Pop(Q2);
            total_money += a -> money;
            total_time += (b -> leave_time - a -> start_time);
            sum_consumer ++;
        }
    }
    while(Q_vip2 -> front != NULL)
    {
        if(Q_vip2->front->money >= 0)
        {
            node *a, *b;
            a = new node;
            b = new node;
            a = Q_vip2->front;
            total_money += a -> money;//存钱
            //离开事件
            b -> type = 1;
            b -> vip = a -> vip;
            b -> num = a -> num;
            b -> money = a -> money;
            b -> leave_time = closetime + 1;
            b -> next = NULL;
            Push(Q_en, b);//放入事件队列
            sum_consumer ++;//客户总数增加
            total_time += (b -> leave_time - a -> start_time);//总时间增加
            if(size(Q_vip2)) Pop(Q_vip2);//让第一队列队首元素出队
        }
        else
        {
            node *a, *b;
            a = new node;
            b = new node;
            a = front(Q_vip2);
            b -> type = 1;
            b -> vip = a -> vip;
            b -> money = a -> money;
            b -> num = a -> num;
            b -> next = NULL;
            b -> leave_time = closetime + 1;
            Push(Q_en, b);
            if(size(Q_vip2)) Pop(Q_vip2);
            total_money += a -> money;
            total_time += (b -> leave_time - a -> start_time);
            sum_consumer ++;
        }
    }
    while(Q_en -> front != NULL)
    {
        if(Q_en -> front -> type == 1)
        {
            //离开
            string res;
            res.clear();
            res = mm_hm(Q_en->front->leave_time);
            char ans[10] = {};
            int i = 0;
            for(auto it : res)
            {
                ans[i] = it;
                i ++;
            }
            if(Q_en->front->leave_time > closetime)
            {
                total_time -= Q_en->front->leave_time - closetime;
                res.clear();
                res = mm_hm(closetime);
                i = 0;
                for(auto it : res)
                {
                    ans[i] = it;
                    i ++;
                }
                if(Q_en->front->money >= 0)
                {
                    char window[10];
                    strcpy(window, "vip窗口");
                    if(Q_en->front-> vip == 1)
                        printf("%10s", window);
                    else printf("%10d", Q_en -> front -> win);
                    printf("%10d%10s%10s%10d   未存款成功", Q_en->front->num, "离开", ans, Q_en->front->money);
                    if(Q_en->front-> vip == 1) cout << " vip\n";
                    else cout << endl;
                    total_money -= Q_en->front->money;
                }
                else
                {
                    char window[10];
                    strcpy(window, "vip窗口");
                    if(Q_en->front-> vip == 1)
                        printf("%10s", window);
                    else printf("%10d", Q_en -> front -> win);
                    printf("%10d%10s%10s%10d   未取款成功", Q_en->front->num, "离开", ans, Q_en->front->money);
                    if(Q_en->front-> vip == 1) cout << " vip\n";
                    else cout << endl;
                    total_money -= Q_en->front->money;
                }
            }
            else
            {
                char window[10];
                strcpy(window, "vip窗口");
                if(Q_en->front-> vip == 1)
                    printf("%10s", window);
                else printf("%10d", Q_en -> front -> win);
                printf("%10d%10s%10s%10d", Q_en->front->num, "离开", ans, Q_en->front->money);
                if(Q_en->front-> vip == 1) cout << " vip\n";
                else cout << endl;
                if(Q_en -> front -> money >= 0)
                {
                    success_in ++;//存款成功
                }
                else
                {
                    success_out ++;//取款成功
                }
            }
        }
        else
        {
            string res;
            res.clear();
            res = mm_hm(Q_en->front->start_time);
            char ans[10] = {};
            int i = 0;
            for(auto it : res)
            {
                ans[i] = it;
                i ++;
            }
            char window[10];
            strcpy(window, "vip窗口");
            if(Q_en->front-> vip == 1)
                printf("%10s", window);
            else printf("%10d", Q_en -> front -> win);
            printf("%10d%10s%10s%10d", Q_en->front->num, "到达", ans, Q_en->front->money);
            if(Q_en->front-> vip == 1) cout << " vip\n";
            else cout << endl;
            if(Q_en -> front -> money >= 0)
            {
                need_in ++;//需要存款
            }
            else
            {
                need_out ++;//需要取款
            }
        }
        if(size(Q_en))Pop(Q_en);
    }
    //清空队列
    for(int i = 0; i < 8; i ++)
        Empty(Q[i]);
    Empty(Q2);
    Empty(Q_en);
    puts("");
    printf("需要存款的客户人数:%d(人)\n", need_in);
    printf("需要取款的客户人数:%d(人)\n", need_out);
    printf("成功存款的客户人数:%d(人)\n", success_in);
    printf("成功取款的客户人数:%d(人)\n", success_out);
    printf("客户逗留总时间:%d(分钟)\n", total_time);
    printf("接待客户总数:%d(人)\n", sum_consumer);
    printf("客户逗留平均时间:%d(分钟)\n", total_time / sum_consumer);
    printf("银行结业余额:%d(元)\n", total_money);
    puts("");
    puts("以上为银行业务模拟结果");

    return 0;
}


标签:node,NULL,管理系统,money,vip,实训,time,front,数据结构
From: https://www.cnblogs.com/shyyyy/p/17384276.html

相关文章

  • 简易图书管理系统
    简易图书管理系统创建Django项目1.pycharm新建Django项目 项目名bms2创建应用app012.修改settings.py MIDDLEWARE注释'django.middleware.csrf.CsrfViewMiddleware'TEMPLATES修改'DIRS':[os.path.join(BASE_DIR,'templates')],文件末尾添加:STATI......
  • 教学管理系统之管理员部分
    现如今管理员部分已经实现完毕,目前为1.0版本登录页面功能页面学生管理教师管理 课程管理 这里面老师和学生如果没有上传头像则为默认头像,添加课程老师中的选项会随着注册老师的数量动态增加,学生老师注册账号需要管理员进行激活还有一些新功能想着添加,不过目......
  • java基于ssm的求职招聘管理系统、校园求职招聘管理系统,附源码+数据库,适合毕业设计、课
    1、项目介绍​该求职招聘网站基于B/S架构,采用SSM框架,运用JSP网页开发技术,并结合MySQL数据库,为招聘者和求职者搭建了一个高效、便捷的网络招聘平台。系统总共有三个角色:求职者、招聘者、管理员​本系统分别为前台求职招聘和后台系统管理,功能如下:​1.前台求职招聘​前台首......
  • 学习JavaScript数据结构与算法 第五章
    五,队列和双端队列我们已经学习了栈。队列和栈非常类似,但是使用了与后进先出不同的原则。双端队列是一种将栈的原则和队列的原则混合在一起的数据结构。5.1队列数据结构队列是遵循先进先出(FIFO,也称为先来先服务)原则的一组有序的项。队列在尾部添加新元素,并从顶部移除元素。最......
  • 33基于Java简单实现图书馆借书管理系统设计与实现
    本章节给大家介绍一个基于Java简单实现图书馆借书管理系统的设计与实现项目概述项目总体分为俩种角色,分别是管理员和阅读者,管理员可以登录系统中,进行图书管理,上架下架图书,对用户进行管理、对读者进行管理、查看借阅记录管理等,读者角色可以登录系统查询图书信息、借阅和归还图......
  • 32基于java的小区物业管理系统或智慧社区管理系统
    本章节给大家介绍一个基于java的小区物业管理系统或智慧社区管理系统,可用于小区物业的管理系统,或者智慧社区的管理系统。系统概要随着科学技术的飞速发展,计算机技术已延伸倒我们日常生活的各个方面。在工业、农业、商业等方面起着巨大的作用。计算机已成为我们日常生活中不可......
  • C/C++数据结构练习题[2023-05-08]
    C/C++数据结构练习题[2023-05-08]基本习题部分1字符串距离目的:字符串是一种基础且广泛使用的数据结构,与字符串相关的题目既可以考察基本程序设计能力和技巧,也可以考查算法设计能力。题目:求字符串之间距离要求:设有字符串X,称在X的头尾及中间插入任意多个空格后构成的新字......
  • 几种常见的Python数据结构
    摘要:本文主要为大家讲解在Python开发中常见的几种数据结构。本文分享自华为云社区《Python的常见数据结构》,作者:timerring。数据结构和序列元组元组是一个固定长度,不可改变的Python序列对象。创建元组的最简单方式,是用逗号分隔一列值:In[1]:tup=4,5,6当用复杂的......
  • java基于springboot+vue非前后端分离的学生成绩管理系统、学生信息管理系统,附源码+数
    1、项目介绍java基于springboot+vue非前后端分离的学生成绩管理系统、学生信息管理系统。本文首先介绍了学生成绩管理的技术发展背景与发展现状,然后遵循软件常规开发流程,首先针对系统选取适用的语言和开发平台,根据需求分析制定模块并设计数据库结构,再根据系统总体功能模块的设计......
  • 【pandas基础】--核心数据结构
    pandas中用来承载数据的两个最重要的结构分别是:Series:相当于增强版的一维数组DataFrame:相当于增强版的二维数组pandas最大的优势在于处理表格类数据,如果数据维度超过二维,一般我们会使用另一个python的库numpy。本篇主要介绍这两种核心数据结构的创建方式。1.Seriespand......