当前位置:网站首页>[队列,栈的简单应用----包装机]
[队列,栈的简单应用----包装机]
2022-07-28 05:26:00 【步步高升b】

#include<iostream>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
struct Queue {
queue<char> que;
};
int main() {
stack<char> arr;
int N,M,S;
string s;
cin>>N>>M>>S;
struct Queue num[N+1];
for (int i = 1; i <= N; i++) {
cin>>s;
for (int j = 0; j < M; j++) {
num[i].que.push(s[j]);
}
}
int x;
while(1) {
cin>>x;
if (x == -1) break;
if (arr.size() < S && x) {
if (!num[x].que.empty())// 筐子未满,轨道有物品的操作。
{
arr.push(num[x].que.front());
num[x].que.pop();
continue;
}
}
if (!x && !arr.empty()) {
cout<<arr.top();// 按钮 0 的操作
arr.pop();
continue;
}
if (arr.size() == S && x ) {
if (num[x].que.empty()) continue;// 轨道上没有物品,不进行任何操作。
cout<<arr.top();
arr.pop();
if (!num[x].que.empty()) {
arr.push(num[x].que.front());//轨道上有物品,筐子里物品已经满了,先取出筐子了物品,再
//将轨道上的物品放入筐中
num[x].que.pop();
}
}
}
}边栏推荐
猜你喜欢
随机推荐
qt解析字符串转为json数据并解析
Relative path and absolute path
自定义组件--数据监听器
如何模拟实现strcpy库函数
刷题记录----二叉树的层序遍历
Vscode中,无法打开源文件 “Adafruit_GFX.h“
Hugging face 的问题记录 I
set_ multicycle_ path
error: redefinition of ‘xxx‘
error: redefinition of ‘xxx‘
结构体、位段、联合体(共用体)的大小如何计算
OpenGL development environment configuration [vs2017] + frequently asked questions
Perl introductory learning (XI) file operation
Several methods of QT setting loading interface
QT custom sliding button (beautiful and easy to use)
Ship detection in SAR image based on yolov5
气传导耳机哪个品牌比较好、这四款不要错过
藏宝计划TPC系统开发Dapp搭建
Word自动目录字体修改和行间距的问题
QT painting event - set background picture









