Project 2: Jumping the Queue The beginning of a winter break near Spring Festival is always the beginning of a peak period of transportation. If you have ever tried to get a train ticket at that time, you must have witnessed the endless queues in front of every ticket box window. If a guy has seen his friend in a queue, then it is very much likely that this lucky guy might go straight to his friend and ask for a favor. This is called "jumping the queue". It is unfair to the rest of the people in the line, but, it is life. Your task is to write a program that simulates such a queue with people jumping in every now and then, assume that, if one in the queue has several friends asking for favors, he would arrange their requests in a queue of his own. Input Specification: Your program must read test cases from a file “input.txt”. The input file will contain one or more test cases. Each test case begins with the number of groups n (1<= n <=1000). Then n group descriptions follow, each one consisting of the number of friends belonging to the group and those people's distinct names. A name is a string of up to 4 characters chosen from {A, B, ..., Z, a, b, ..., z}. A group may consist of up to 1000 friends. You may assume that there is no one belong to two different groups. Finally, a list of commands follows. There are three different kinds of commands:  ENQUEUE X - Mr. or Ms. X goes into the queue  DEQUEUE - the first person gets the ticket and leave the queue  STOP - end of test case The input will be terminated by a value of 0 for n. Output Specification: For each test case, output to a file “output.txt”. First print a line saying "Scenario #k", where k is the number of the test case. Then, for each DEQUEUE command, print the person who just gets a ticket on a single line. Print a blank line between two test cases, but no extra line at the end of output. Sample Input: 2 3 Ann Bob Joe 3 Zoe Jim Fat ENQUEUE Ann ENQUEUE Zoe ENQUEUE Bob ENQUEUE Jim E
2020-01-13 03:16:55 37KB Jumping the Queue
1
链式队列是不同于循环数组的另一种队列的实现形式。队列中的元素以Node形式存储。节点Node中存有此节点存于队列中的元素以及指向下一个元素的指针。链式队列的需要保存指向队头和队尾的指针的数据成员。 参见博客:http://blog.csdn.net/xiaowei_cqu/article/details/7748247
2019-12-21 22:02:10 823KB Linked Queue
1
java队列实现(顺序队列、链式队列、循环队列)
2019-12-21 20:59:35 12KB java queue 队列
1
gem5底层如何实现模拟处理器并行执行的?如何实现准确计算cycle数?
2019-12-21 20:29:03 238KB gem5 event queue
1
最低2分,而且摘要必须大于50个字节,不知道用的是什么编码,,
2019-12-21 20:28:35 34KB C# Concurrent Queue 队列
1
c语言实现的模板,实现方法是使用void指针和size 包括list queue stack三种
2018-04-24 09:59:11 4KB c语言 模板 list queue
1