#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的更多相关文章

  1. HDU 1702 http://acm.hdu.edu.cn/showproblem.php?pid=1702

    #include<stdio.h> #include<string.h> #include<queue> #include<stack> #define ...

  2. HDU 4911 http://acm.hdu.edu.cn/showproblem.php?pid=4911(线段树求逆序对)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911 解题报告: 给出一个长度为n的序列,然后给出一个k,要你求最多做k次相邻的数字交换后,逆序数最少 ...

  3. 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 ...

  4. HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632

    http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...

  5. 待补 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/ ...

  6. hdu Train Problem I(栈的简单应用)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  7. 栈的简单应用 HDU 1022 http://acm.hdu.edu.cn/showproblem.php?pid=1022

    #include<stdio.h> #include<stack> #include<string.h> #define N 20 using namespace ...

  8. HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257

    Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...

  9. 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 ...

随机推荐

  1. 宏HASH_GET_NEXT

    /*******************************************************************//** Gets the next struct in a h ...

  2. UVa 10943 (数学 递推) How do you add?

    将K个不超过N的非负整数加起来,使它们的和为N,一共有多少种方法. 设d(i, j)表示j个不超过i的非负整数之和为i的方法数. d(i, j) = sum{ d(k, j-1) | 0 ≤ k ≤ ...

  3. 面向函数范式编程(Functional programming)

    函数编程(简称FP)不只代指Haskell Scala等之类的语言,还表示一种编程思维,软件思考方式,也称面向函数编程. 编程的本质是组合,组合的本质是范畴Category,而范畴是函数的组合. 首先 ...

  4. poj 1364 King(差分约束)

    题意(真坑):傻国王只会求和,以及比较大小.阴谋家们想推翻他,于是想坑他,上交了一串长度为n的序列a[1],a[2]...a[n],国王作出m条形如(a[si]+a[si+1]+...+a[si+ni ...

  5. 工作中的 Vim 和 git

    ————————Vim———————— 1. gf 可以转到文件中指明路径的文件. 这样可以实现文件的快速切换. ctrl+o: A -> B,  返回A ctrl+6: A.B之间快速切换 2 ...

  6. 最简单的视音频播放示例4:Direct3D播放RGB(通过Texture)

    本文接着上一篇文章继续记录Direct3D(简称D3D)播放视频的技术.上一篇文章中已经记录了使用Direct3D中的Surface渲染视频的技术.本文记录一种稍微复杂但是更加灵活的渲染视频的方式:使 ...

  7. Oracle 手工清除回滚段的几种方法

    关于回滚段的问题,之前也小整理过一个,参考: Current online Redo 和 Undo 损坏的处理方法 http://blog.csdn.net/tianlesoftware/articl ...

  8. Android中FragmentPagerAdapter对Fragment的缓存(一)

    ViewPager + FragmentPagerAdapter,时我们经常使用的一对搭档,其实际应用的代码也非常简单,但是也有一些容易被忽略的地方,这次我们就来讨论下FragmentPagerAda ...

  9. HDU 5730 Shell Necklace cdq分治+FFT

    题意:一段长为 i 的项链有 a[i] 种装饰方式,问长度为n的相连共有多少种装饰方式 分析:采用dp做法,dp[i]=∑dp[j]*a[i-j]+a[i],(1<=j<=i-1) 然后对 ...

  10. HDU-1438 钥匙计数之一

    http://acm.hdu.edu.cn/showproblem.php?pid=1438                                钥匙计数之一 Time Limit: 200 ...