HDU 1702
来源:互联网 发布:淘宝头像画师招聘 编辑:程序博客网 时间:2024/05/20 22:02
这是一道简单的模拟题目,就是根据题目的要求敲代码!没什么算法!练练代码能力!这题也提到队列和栈!队列是先进先出,栈是先进后出!
AC代码如下:
//#include <iostream>
#include <stdio.h>
#include <string.h>
//using namespace std;
int main()
{
int t,n,i,a,b;
char str1[6], str2[6];
int c[1000];
scanf("%d",&t);
while(t--)
{
scanf("%d %s",&n,str1);
a=0;
b=0;
while(n--)
{
getchar();
scanf("%s",str2);
if(strcmp(str2,"IN")==0)
{
scanf("%d",&c[b++]);
}
else if(strcmp(str2,"OUT")==0)
{
if(strcmp(str1,"FIFO")==0)
{
if(a<b)
{
printf("%d\n",c[a++]);
}
else
{
puts("None");
a=0;
b=0;
}
}
else if(strcmp(str1,"FILO")==0)
{
if(a<b)
{
printf("%d\n",c[--b]);
}
else
{
puts("None");
a=0;
b=0;
}
}
}
}
}return 0;
}
- HDU 1702
- hdu 1702
- HDU 1702
- HDU-1702
- HDU 1702
- hdu 1702 暴力
- hdu 1702 水水
- HDU 1702 STL
- HDU 1702 FIFO FILO
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- 15条SQLite3语句
- 第41章、记录速改(一)
- 9个offer,12家公司,35场面试,从微软到谷歌,应届计算机毕业生的2012求职之路(强烈顶,学习榜样!)
- 黑马程序员--委托的好处与事件学习
- 获取字符串长度的几种办法
- HDU 1702
- selenium webdriver学习(六)------------如何得到弹出窗口
- @SuppressWarnings(unchecked)
- jdbc 事务的隔离级别
- 第42章、记录速改
- android surfaceflinger研究----显示系统, Surface机制, SurfaceFlinger loop
- ubuntu同步CM7源码并编译V880刷机包
- 第43章、分页显示
- android recovery模式及ROM制作