• 大小: 0.01M
    文件类型: .cpp
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: C/C++
  • 标签: 其他  

资源简介

bank.cpp

资源截图

代码片段和文件信息

/*
  Name: 银行排队取号系统模拟
  Copyright: 
  Author: ***
  Date: 13/04/09 12:45
  Description: 
*/



#include 
#include 

//-----------------各个窗口业务队列 ---------------

//typedef int Elem;

typedef struct qNode{
        int val;
        qNode* next;
}qNode *qPoint; 

typedef struct {
        int length;
        qPoint front;
        qPoint rear;
}Bankqueue;

void initQueue(Bankqueue& b){
     b.front = b.rear = (qPoint)malloc(sizeof(qNode));
     if(!b.front)exit(0);
     b.front->next = NULL;
     b.length = 0;
}

void destryQueue(Bankqueue& ql){
     while (ql.front){
           ql.rear = ql.front->next;
           free(ql.front);
           ql.front = ql.rear;
     }
}

void push(Bankqueue& b int e){
     qPoint p;
     p = (qPoint)malloc(sizeof(qNode));
     if(!p)exit(0);
     p->val = e;
     b.rear->next = p;
     b.rear = p;
     b.length++;
}

void pop(Bankqueue& b){
//     if(b.front->next){
            if (b.front != b.rear){
                 qPoint t;
                 t = b.front->next;
                 if (b.rear == t){
                            b.rear = b.front;
                            b.front->next =NULL;
                 }else{
                       b.front->next = t->next;
                 }
                 
                 free(t);
                 b.length--;
            }
//    }
}

int front(Bankqueue b){
     if (b.front != b.rear){
                 return b.front->next->val;
     }
}

bool empty(Bankqueue b){
     return b.length == 0;


//-------------------银行卡窗口间队列 --------------------


//typedef struct bNode{
//        Bankqueue val;
//        bNode* next;
//}bNode *bPoint; 

//typedef struct {
//        int length;
//        bPoint front;
//        bPoint rear;
//}Operationqueue;

//void initOpQueue(Operationqueue& b){
//     b.front = b.rear = (bPoint)malloc(sizeof(bNode));
 //    if(!b.front)exit(0);
//     b.front->next = NULL;
//     b.length = 0;
//}

//void pushb(Operationqueue& b Bankqueue e){
 //    bPoint p;
 //    p = (bPoint)malloc(sizeof(bNode));
 //    if(!p)exit(0);
 //    p->val = e;
//     b.rear->next = p;
//     b.rear = p;
//     b.length++;
//}

//Bankqueue frontb(Operationqueue b){
//     if (b.front != b.rear){
//                 return b.front->val;
 //    }
//}

//void popb(Operationqueue& b){
//     if(!b.front){
//            if (b.front != b.rear){
//                 bPoint t;
//                 t = b.front->next;
//                 if (b.rear == t){
 //                           b.rear = b.front;
//                 }
//            }
//     }
//}

//------------------各业务选项方法--------------- 
//void operationOne(Bankqueue&  int);    //公积金队列 
//void operationTwo(Bankqueue& Bankqueue&  int int []); //银行卡队列、银行卡窗口队列、当前客户取号、银行卡窗口数组 
//void operationThree(Bankqueue& a Bankqueue& b int i int B[]); //理财卡队列、银行卡队列、当前取得理财卡排除号、银行卡窗口数组 
//----

评论

共有 条评论