博客
关于我
算法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/

你可能感兴趣的文章
Oracle EBS环境下查找数据源(OAF篇)
查看>>
oracle Extract 函数
查看>>
uni-app开发环境自动部署的一个误区(App running at...)
查看>>
Oracle GoldenGate Director安装和配置(无图)
查看>>
Oracle Goldengate在HP平台裸设备文件系统OGG-01028处理
查看>>
oracle instr函数详解
查看>>
Oracle Java所有版本的下载链接
查看>>
Oracle JDBC url的几种方式
查看>>
Oracle JDBC 连接卡死后 Connection Reset
查看>>
Oracle JDK vs OpenJDK
查看>>
ORACLE MERGE INTO (2)
查看>>
oracle ogg 单实例双向复制搭建(oracle-oracle)--Oracle GoldenGate
查看>>
Oracle ora-12514报错解决方法
查看>>
oracle ORA-14402 OGG-01296
查看>>
oracle package包头和package body包体例子
查看>>
oracle partition by list,深入解析partition-list 分区
查看>>
Oracle PL/SQL Dev工具(破解版)被植入勒索病毒的安全预警及自查通告
查看>>
oracle pl/sql 导出用户表结构
查看>>
Oracle PLSQL Demo - 17.游标查询个别字段(非整表)
查看>>
【C/C++学院】(6)构造函数/析构函数/拷贝构造函数/深copy浅copy
查看>>