博客
关于我
算法C++ 先进先出队列银行排号系统STL库实现(第一章)
阅读量:201 次
发布时间:2019-02-28

本文共 842 字,大约阅读时间需要 2 分钟。

造轮子博客链接


代码实现

#include   #include   using namespace std;  int main(){ int temp; int customers_count = 0; unsigned maxnumber = 10; //银行今天接待人数限制 queue number_line; cout << "bank only receive " << maxnumber << " people today" << endl;  cout << "customers over maxnumber or input '-1' stop serving" << endl;  cout << "input your number" << endl;  while (cin >> temp) {      if (temp == -1 || number_line.size() == maxnumber) {          if (number_line.size() == maxnumber) {              cout << "sorry the customers are too many! please next day comes!" << endl;          }          break;      }      number_line.push(temp);  }  return 0;  }


实现效果

通过这个简单的程序,我们可以模拟一个银行接待人数的系统。程序使用队列数据结构来管理接待的顾客数量,当达到最大值时会提示顾客下次来店。

程序的主要逻辑是:读取用户输入的数字,直到达到最大值10或用户输入-1为止。输入的数字会被添加到队列中,队列的大小限制了接待人数。当队列达到最大值时,程序会提示"抱歉,今天的人数太多了,请下次再来"。

这个程序简单实用,适合用于教学或演示队列数据结构的基本应用。

转载地址:http://mfni.baihongyu.com/

你可能感兴趣的文章
Symbolic Aggregate approXimation(SAX,符号聚合近似)介绍-ChatGPT4o作答
查看>>
Orcale表被锁
查看>>
svn访问报错500
查看>>
sum(a.YYSR) over (partition by a.hy_dm) 不需要像group by那样需要分组函数。方便。
查看>>
ORCHARD 是什么?
查看>>
Struts2中使用Session的两种方法
查看>>
Stream API:filter、map和flatMap 的用法
查看>>
STM32工作笔记0032---编写跑马灯实验---寄存器版本
查看>>
Static--用法介绍
查看>>
ssm旅游信息管理系统的设计与实现bus56(程序+开题)
查看>>
order by rand()
查看>>
SSM(Spring+SpringMvc+Mybatis)整合开发笔记
查看>>
ViewHolder的改进写法
查看>>
Orderer节点启动报错解决方案:Not bootstrapping because of 3 existing channels
查看>>
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement profile
查看>>
sql查询中 查询字段数据类型 int 与 String 出现问题
查看>>
org.apache.commons.beanutils.BasicDynaBean cannot be cast to ...
查看>>
org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: not s
查看>>
sqlserver学习笔记(三)—— 为数据库添加新的用户
查看>>
org.apache.http.conn.HttpHostConnectException: Connection to refused
查看>>