使用循环链表实现一个双向队列并且实现出队列和进队列的编程算法, 使用C语言的编程?

Problem Description
ACboy was kidnapped!!
he miss his mother very much and is very scare now.You can't image how dark the room he was put into is, so poor :(.
As a smart ACMer, you want to get ACboy out of the monster's labyrinth.But when you arrive at the gate of the maze, the monste say :" I have heard that you are very clever, but if can't solve my problems, you will die with ACboy."
The problems of the monster is shown on the wall:
Each problem's first line is a integer N(the number of commands), and a word "FIFO" or "FILO".(you are very happy because you know "FIFO" stands for "First In First Out", and "FILO" means "First In Last Out").
and the following N lines, each line is "IN M" or "OUT", (M represent a integer).
and the answer of a problem is a passowrd of a door, so if you want to rescue ACboy, answer the problem carefully!

Input
The input contains multiple test cases.
The first line has one integer,represent the number oftest cases.
And the input of each subproblem are described above.

Output
For each command "OUT", you should output a integer depend on the word is "FIFO" or "FILO", or a word "None" if you don't have any integer.

Sample Input
4
4 FIFO
IN 1
IN 2
OUT
OUT
4 FILO
IN 1
IN 2
OUT
OUT
5 FIFO
IN 1
IN 2
OUT
OUT
OUT
5 FILO
IN 1
IN 2
OUT
IN 3
OUT

Sample Output
1
2
2
1
1
2
None
2
3

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

0
用python实现双向循环链表的问题
1
循环链表的顺序实现出现一个问题(抛异常)
2
Java语言编写程序一个链表,并且计算链表上所有数的和
1
重赏求助,用java eclipse,分别用二叉链表、三叉链表为成员方法,查找二叉树中某节点的父节点?
1
以二叉链表建立二叉树链式存储结构,实现前序遍历、求叶子结点的个数计算、中序遍历、后序遍历、求深度。
1
C语言:合并有序双向链表问题
1
验证线性表及其上的基本操作。
2
编写一个函数,实现将一个带头结点的单向链表数据逆置,代码怎么写呀?
2
C语言约瑟夫循环,不使用链表,依靠指针和循环实现?
1
将两个递增的双向链表合并问题
1
今年刚刚学的C语言,没有学过链表希望大佬可以帮忙写一下源代码,谢谢了
0
Java语言设计实现一个链表的数据结构,不要使用现有的库的代码,并且插入5个数字再输出
2
这是一个关于数据结构链表结点的相关问题
2
这是一个关于链表结点的指针问题
1
这是一个关于数据结构的链表问题
2
这是一个关于链表的取值问题
1
如何理解链表中指针和节点的意义
2
请问有没有一种 O(V+E)的算法可以判断给定的一个图的邻接链表是否存在任何平行边?(判断这个邻接链表的图是否属于多重图)
2
设计一种O(V+E)的算法来将给定的一个图的邻接链表中包含的顶点按由小到大的顺序排列。