Queue

17.2 - Queue basic 2


Your task is to create a program to simulate grocery store queues. In a single grocery store there can be multiple checkout lines with their own queue, in this task you have to create two queues to simulate two checkout lines.

Each person in the checkout line is represented by a number starting from 1 since it is their codename. This means your queue should store integers.

The program accepts the following commands.

  • enqueue
    Creates a new person with a number one bigger than the previous one and enqueue him to the queue with least amount of people or the first queue if there are the same amount of people on both queues. This should also print out "Enqueue [number] at the [first/second] queue."
  • checkout
    This removes the person on the front of the specified queue. This should also print out "[number] checked out at the [first/second] queue."

Sample input

enqueue
enqueue
enqueue
checkout first
checkout second
enqueue
enqueue
checkout second
checkout first
checkout first

Sample output

Enqueue 1 at the first queue.
Enqueue 2 at the second queue.
Enqueue 3 at the first queue.
1 checked out at the first queue.
2 checked out at the second queue.
Enqueue 4 at the second queue.
Enqueue 5 at the first queue.
4 checked out at the second queue.
3 checked out at the first queue.
5 checked out at the first queue.
#include <queue> #include <iostream> int main() { }