HDU 1702 队列与栈的简单运用http://acm.hdu.edu.cn/showproblem.php?pid=1702
#include<stdio.h>
#include<string.h>
#include<queue>
#include<stack>
#define N 10
using namespace std; void Q(int n)
{
int m;
char s[N];
queue<int>Q;
while(n--)
{
scanf("%s", s);
if(strcmp(s, "IN") == )
{
scanf("%d", &m);
Q.push(m);
}
else if(strcmp(s, "OUT") == )
{
if(Q.empty())
printf("None\n");
else
{
printf("%d\n", Q.front());
Q.pop();
}
}
} } void S(int n)
{
stack<int>S;
char s[N];
int m;
while(n--)
{
scanf("%s", s);
if(strcmp(s, "IN") == )
{
scanf("%d", &m);
S.push(m);
}
else if(strcmp(s, "OUT") == )
{
if(S.empty())
{
printf("None\n");
}
else
{
printf("%d\n", S.top());
S.pop();
}
}
}
}
int main()
{
int t, n;
char s[N];
scanf("%d", &t);
while(t--)
{
scanf("%d%s", &n, s);
if(strcmp(s, "FIFO") == )
Q(n);
else if(strcmp(s, "FILO") == )
S(n);
}
return ;
}
HDU 1702 队列与栈的简单运用http://acm.hdu.edu.cn/showproblem.php?pid=1702的更多相关文章
- HDU 1702 http://acm.hdu.edu.cn/showproblem.php?pid=1702
#include<stdio.h> #include<string.h> #include<queue> #include<stack> #define ...
- HDU 4911 http://acm.hdu.edu.cn/showproblem.php?pid=4911(线段树求逆序对)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911 解题报告: 给出一个长度为n的序列,然后给出一个k,要你求最多做k次相邻的数字交换后,逆序数最少 ...
- KMP(http://acm.hdu.edu.cn/showproblem.php?pid=1711)
http://acm.hdu.edu.cn/showproblem.php?pid=1711 #include<stdio.h> #include<math.h> #inclu ...
- HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632
http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...
- 待补 http://acm.hdu.edu.cn/showproblem.php?pid=6602
http://acm.hdu.edu.cn/showproblem.php?pid=6602 终于能够看懂的题解: https://blog.csdn.net/qq_40871466/article/ ...
- hdu Train Problem I(栈的简单应用)
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...
- 栈的简单应用 HDU 1022 http://acm.hdu.edu.cn/showproblem.php?pid=1022
#include<stdio.h> #include<stack> #include<string.h> #define N 20 using namespace ...
- HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257
Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...
- http://acm.hdu.edu.cn/showproblem.php?pid=2579
#include<stdio.h> #include<string.h> #include<queue> #define N 110 int m, n, k, x1 ...
随机推荐
- 使用UIL(Universal-Image-Loader)异步加载图片
概要: Android-Universal-Image-Loader是一个开源的UI组件程序,该项目的目的是实现可重复使用的异步图像加载.缓存和显示.所以,如果你的程序里需要这个功能的话,使用它,因为 ...
- 让IE6下支持固定定位
让IE下支持固定定位 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...
- JSP学习笔记(1)
JSP本质就是一个servlet,当第一次接受到客户端请求时会被编译成对应的servlet,且对应的每个servlet在容器中只要一个实例. 1.1.JSP注释 <%-- JSP注释部分 --& ...
- C# 通过豆瓣网络编程API获取图书信息
这篇文章主要是关于如何通过豆瓣API获取信息的书籍,起初,我看到了原来的想法的内容是"C# 网络编程之网页简单下载实现"中通过HttpWebResponse类下载源代码,再通过正則 ...
- .eslintrc 文件
安装 建议采用全局安装方式 npm install -g eslint 初始化 如果你的项目还没有配置文件(.eslintrc)的话,可以通过指定–init参数来生成一个新的配置文件: `eslint ...
- centos7 安装mysql出现Could NOT find Curses (missing CURSES_LIBRARY CURSES_INCLUDE_PATH)
今天安装mysql 5.7 编译时出现一下问题: [root@localhost software]# cd mysql-5.7.21 [root@localhost mysql-5.7.21]# c ...
- hibernate关联关系映射之配置文件
词汇解释 关系:事物之间相互作用.相互联系的状态.范围最大. 联系:在关系数据库中表示实体与实体之间的联系,1:1,1:n,m:n. 关联:表示对象之间的关系,既有数量性,又有方向性:动词:将对象之间 ...
- Centos6安装FreeSWITCH 1.5时./configure问题解决记录
系统:Centos 6.4 64位: FreeSWITCH版本:1.5 具体的安装过程参考FreeSWITCH 官网wiki (也可以参考我的博客<Centos6安装FreeSWITCH> ...
- linux内核添加模块
参考: http://blog.csdn.net/gaoguoxin2/article/details/50220665 动态添加模块不需要编译内核. LINUX的模块主要由6部分组成: 1.模块的加 ...
- Python应用场景 (转)
Web应用开发 Python经常被用于Web开发.比如,通过mod_wsgi模块,Apache可以运行用Python编写的Web程序.Python定义了WSGI标准应用接口来协调Http服务器与基于P ...