排队做操迟到 c++

时间: 2023-11-24 22:51:48 浏览: 55
以下是C++实现排队做操迟到的代码: ```cpp #include<iostream> #include<queue> using namespace std; int main(){ queue<string> q; int n; cin >> n; for(int i = 0; i < n; i++){ string name; cin >> name; q.push(name); } int m; cin >> m; for(int i = 0; i < m; i++){ string name; cin >> name; while(!q.empty()){ string front_name = q.front(); q.pop(); if(front_name != name){ q.push(front_name); }else{ break; } } } while(!q.empty()){ cout << q.front() << endl; q.pop(); } return 0; } ```
相关问题

窗口排队管理系统c++

下面是一个简单的窗口排队管理系统的 C++ 代码示例: ```c++ #include <iostream> #include <queue> using namespace std; struct Customer { int id; int service_time; }; int main() { queue<Customer> customers; int num_customers; int total_service_time = 0; cout << "请输入顾客数量:" << endl; cin >> num_customers; for (int i = 1; i <= num_customers; i++) { Customer customer; customer.id = i; cout << "请输入顾客 " << i << " 的服务时间:" << endl; cin >> customer.service_time; customers.push(customer); } cout << "当前窗口空闲" << endl; while (!customers.empty()) { Customer customer = customers.front(); customers.pop(); total_service_time += customer.service_time; cout << "顾客 " << customer.id << " 开始服务,服务时间为 " << customer.service_time << ",累计服务时间为 " << total_service_time << endl; } cout << "所有顾客服务结束,总服务时间为 " << total_service_time << endl; return 0; } ``` 在这个示例中,顾客被定义为一个结构体,包含顾客的编号和需要的服务时间。使用 `queue` 存储所有顾客,然后依次处理每个顾客,计算累计服务时间。最终输出总服务时间。 这只是一个简单的示例,实际的窗口排队管理系统可能需要更复杂的逻辑和功能。

银行窗口排队管理系统C++

好的,下面是一个简单的银行窗口排队管理系统的 C++ 代码示例: ```c++ #include <iostream> #include <queue> #include <string> using namespace std; class Customer { public: string name; int age; string id; string phone; }; class QueueManager { private: queue<Customer> q; public: void addCustomer(Customer customer) { q.push(customer); } void serveNextCustomer() { if (!q.empty()) { Customer c = q.front(); q.pop(); cout << "服务客户:" << c.name << endl; } else { cout << "暂无客户排队" << endl; } } }; int main() { QueueManager qm; Customer c1 = {"Tom", 25, "123456", "13888888888"}; Customer c2 = {"Lucy", 30, "654321", "13999999999"}; qm.addCustomer(c1); qm.addCustomer(c2); qm.serveNextCustomer(); // 服务客户:Tom qm.serveNextCustomer(); // 服务客户:Lucy qm.serveNextCustomer(); // 暂无客户排队 return 0; } ``` 上述代码实现了一个简单的银行窗口排队管理系统,包含 Customer 类和 QueueManager 类。其中 Customer 类表示客户信息,QueueManager 类表示排队管理系统,包含添加客户、服务下一个客户和暂无客户排队三个方法。您可以根据需要进行修改和扩展。

相关推荐

最新推荐

recommend-type

C++面试八股文深度总结

根据自己备战22届秋招(斩获华为、荣耀、联发科、海康威视等offer)总结的相关知识,其中包括C++基础知识、操作系统、计算机网络、数据库等知识。希望对读者有帮助,助其在找工作的路上少走弯路,收获自己心仪的...
recommend-type

c++入门,核心,提高讲义笔记

最详细的c++入门,核心,提高讲义笔记,看会成为大佬没问题,下载后有疑问请私信。
recommend-type

c++读取excel的代码详解

c++如何读取excel?C++ ODBC操作excel全过程 想要通过ODBC直接读、写Excel表格文件,首先,应确保ODBC中已安装有Excel表格文件的驱动”MICROSOFT EXCEL DRIVER (*.XLS)”。然后,可根据下面步骤进行: 1. 在StdAfx.h...
recommend-type

C++-ISO (2020).pdf

C++2020标准,I S O ( t h e I n t e r n a t i o n a l O r g a n i z a t i o n fo r S t a n d a r d i z a t i o n ) i s a w o r l d w i d e fe d e r a t i o n o f n a t i o n a l s t a n d a r d s b o d...
recommend-type

C++设置超时时间的简单实现方法

主要介绍了C++设置超时时间的简单实现方法,涉及系统函数setsockopt对套接口的操作,具有一定的实用价值,需要的朋友可以参考下
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。