博客
关于我
算法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 批量生成建同义词语句和付权语句
查看>>
oracle 抓包工具,shell 安装oracle和pfring(抓包) 及自动环境配置
查看>>
Oracle 拆分以逗号分隔的字符串为多行数据
查看>>
Oracle 排序中使用nulls first 或者nulls last 语法
查看>>
oracle 插入date日期类型的数据、插入从表中查出的数据,使用表中的默认数据
查看>>
Oracle 操作笔记
查看>>
oracle 数据库 安装 和优化
查看>>
oracle 数据库dg搭建规范1
查看>>
Oracle 数据库常用SQL语句(1)
查看>>
Oracle 数据库特殊查询总结
查看>>
Oracle 数据类型
查看>>
Oracle 数据自动备份 通过EXP备份
查看>>
oracle 数据迁移 怎么保证 和原表的数据顺序一致_一个比传统数据库快 1001000 倍的数据库,来看一看?...
查看>>
oracle 时间函数
查看>>
oracle 时间转化函数及常见函数 .
查看>>
Oracle 权限(grant、revoke)
查看>>