C++链式队列实现简易银行叫号系统

该博客介绍了如何使用C++实现一个简单的银行叫号系统,包括用户排队、VIP和公务客户优先处理等功能。代码部分展示了用户类、窗口类以及模拟器类的设计,通过手动运行方式进行展示,并提供了测试结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.实现功能

  • 用户进入队列排队等待
  • 银行窗口办理业务
  • VIP客户及公务客户优先办理
  • VIP及公务窗口闲置时可以为普通用户办理业务

2.注意

  • 为节约空间,仅在博客中提供部分代码
  • 本程序采用手动运行方式而非随时间自动运行,不过很容易就可以改成自动运行

3.代码部分

#include<iostream>
#include<windows.h>
#include<conio.h>

using namespace std;

int alltime=0; //程序总运行时间

struct Node{
   
   
	int data;
	Node *next;
}; 
 
class Lqueue{
   
     //采用链式队列
	private:
		Node *front,*rear;
		int time;
	public:
		int len=0;
		Lqueue(){
   
   
			front=rear=NULL;
			time=0;
		}
		bool enqueue(int num);
		bool dequeue(int &num);
		void clear();
		void show();
		~Lqueue(){
   
   
			clear();
		}
};  //链式队列函数实现很容易,就不贴出来了

以下为用户类的定义及三种用户的定义

class User{
   
   
	public:
		int type;
		int waittime;  //等待时间 
		int sertime=0;  //已服务时间 
		int id=0; //用户编码 
}; 

class Nuser:public User{
   
    //Normal User 
	public:
		Nuser(){
   
   
			type=1;
			waittime=0;
			sertime=0; 
		}
};

class Vuser:public User{
   
    //VIP User
	public:
		Vuser(){
   
   
			type=2;
			waittime=0;
			sertime=0; 
		}
};

class Ouser:public User{
   
    //公务客户
	public:
		Ouser(){
   
   
			type=3;
			waittime=0;
			sertime=0; 
		}
};

以下为银行窗口类及三种不同窗口

class Bankwindow{
   
   
	public:
		int full=0;//0为空,1为满 
		int start=0;   //start=0表示未开始服务,=1表示开始服务 
		int starttime=0;
		int servetime(); //返回办理业务所用时间 
		void serve();  //办理业务
};

void Bankwindow::serve(){
   
   
	int nowtime=0;
	nowtime=alltime;
	if(full==1
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值