Queue with Error Protection#203

Queue with Error Protection

1 second
64 megabytes
Very easy (≈850)

Implement a extttqueue data structure. Develop a program that provides a description of the queue and simulates the operation by implementing all provided methods. The program reads consecutive commands and performs operations based on those commands. After executing each command, the program should output a single line. The possible commands for the program are:

push n

Add the number n to the queue (the value of n is provided after the command). The program should output ok.

pop

Remove the first element from the queue. The program should output its value.

front

Output the first element without removing it from the queue.

size

Output the number of elements in the queue.

clear

Clear the queue and output ok.

exit

Output bye and terminate the program.

Before executing the front and pop commands, the program should check whether there is at least one element in the queue. If front or pop is given in the input and the queue is empty, the program should output the line error.

Input

Described in the statement. Refer to the sample input data as well.

Output

Described in the statement. Refer to the sample output data as well.

Examples

Example 1

Loading
Loading