Error-Correcting Queue#6126

Error-Correcting Queue

1 Sekunde
64 Megabyte
Sehr leicht

Implement a data structure called a "queue". Write a program that contains the description of the queue and simulates its operation by implementing all methods specified below. The program reads a sequence of commands, performing an operation for each command. After each command, the program should output a single line. The possible commands are:

Before executing the front or pop operations, the program must check whether the queue contains at least one element. If front or pop is requested and the queue is empty, the program should output the string error instead of a numerical value.

Eingabe

The input contains the commands as described above, one per line. See the input example.

Ausgabe

The program should output a line for each command as described above. See the output example.

Beispiele

Beispiel 1

Loading
Loading