试编写一个程序模拟银行大厅叫号功能。 〔问题描述〕每当有客户到来时,可以选择个人业务或公司业务,个人业务和公司业务将分别进行排队,同时在屏幕上显示当前客户的排队号和前面还有多少人;当服务员按下服务按键时,则在屏幕上显示第多少号客户。只要无问题,可加钱。
没有说设计菜单和键盘输入这些具体的要求,就简单模拟一下即可
#include <iostream>
#include <queue>
#include <string>
using namespace std;
//业务
struct business
{
string name; //客人姓名
int type; //业务类型 个人0 公司1
string content; //业务内容 存款、取款、转账等
};
//银行
class bank
{
public:
bank() {}
public:
//欢迎
void welcome(string name)
{
cout << name << ",欢迎您来到银行!" << endl;
}
//排号
void takenum(business &b)
{
welcome(b.name);
//个人业务
if (b.type == 0)
{
person.push(b);
cout << "您的号数为 000" << person.size() - 1 << endl;
cout << "您前面还有" << person.size()-1 << "人!" << endl;
cout << endl;
}
//公司业务
else if (b.type == 1)
{
company.push(b);
cout << "您的号数为 100" << company.size() - 1 << endl;
cout << "您前面还有" << company.size() - 1 << "人!" << endl;
cout << endl;
}
else { cout << "输入有误" << endl; }
}
private:
queue<business> person; //个人业务
queue<business> company; //公司业务
};
int main()
{
business b1;
b1.name = "zhangsan";
b1.type = 0;
b1.content = "取款5万";
business b2;
b2.name = "lisi";
b2.type = 0;
b2.content = "取款5万";
business b3;
b3.name = "wangwu";
b3.type = 0;
b3.content = "取款5万";
business b4;
b4.name = "信息技术有限公司";
b4.type = 1;
b4.content = "转账50万到游戏公司";
business b5;
b5.name = "游戏公司";
b5.type = 1;
b5.content = "贷款100万";
bank b;
b.takenum(b1);
b.takenum(b2);
b.takenum(b3);
b.takenum(b4);
b.takenum(b5);
return 0;
}
整两个队列就行了。
我有一整套的成熟的排队叫号程序不过是Java的
包括取票叫号后台