SDUT 2135 数据结构实验之队列一:排队买饭
2016-06-19 15:08
274 查看
点击打开题目链接
#include <bits/stdc++.h> using namespace std; int _queue[10010]; int main() { int n, m, top = 0; char s[10]; cin >> m; for(int i = 0; i < m; i++) { int a; cin >> a; _queue[++top] = a; } cin >> n; while(n --) { scanf("%s", s); if(strcmp(s, "JOIN") == 0) { int a; cin >> a; _queue[++top] = a; } else if(strcmp(s, "ASK") == 0) { int a; cin >> a; cout << _queue[a] << endl; } else if(strcmp(s, "LEAVE") == 0) { int a; cin >> a; for(int i = a; i < top; i++) { _queue[i] = _queue[i+1]; } --top; } else if(strcmp(s, "LENGTH") == 0) { cout << top << endl; } else if(strcmp(s, "FINISH") == 0) { int a, k = 0; cin >> a; for(int i = 1; i <= top-a; i++) { _queue[i] = _queue[i+a]; } top -= a; } } return 0; }
相关文章推荐
- C#线程队列用法实例分析
- 算法系列15天速成 第九天 队列
- C语言单链队列的表示与实现实例详解
- mysql 队列 实现并发读
- C#队列Queue用法实例分析
- C#多线程处理多个队列数据的方法
- C语言循环队列的表示与实现实例详解
- C++循环队列实现模型
- C#内置队列类Queue用法实例
- Array栈方法和队列方法的特点说明
- C#通过链表实现队列的方法
- C#队列Queue多线程用法实例
- C#数据结构与算法揭秘五 栈和队列
- C++中队列的建立与操作详细解析
- PHP实现的memcache环形队列类实例
- php基于双向循环队列实现历史记录的前进后退等功能
- 队列在编程中的实际应用(php)
- Go语言的队列和堆栈实现方法
- C++队列用法实例
- PHP队列用法实例