資源簡介
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[]);?//理財卡隊列、銀行卡隊列、當前取得理財卡排除號、銀行卡窗口數組?
//----
- 上一篇:FIR濾波器的C語言實現
- 下一篇:八數碼游戲程序人工智能,c++
評論
共有 條評論