Hi for me this is th first time that I use c++. I have to do this exercise. Somebody can help me?
Thanx.
Implement a FIFO-queue ( first in, first out ) as a ring buffer. Use a static array as the data structure. The program needs to be able to add elements to the end of the queue, tell the value of the oldest element and remove from the queue. The capacity n of the ring buffer is 10000 elements.
The program must handle the following commands:
L k Read in an integer k, push it to the end of the queue and print "L". If the queue is already full, just print an error message "V".
T Print the value of the oldest element in the queue. If the queue is empty, print "V".
P Print the value of the oldest element in the queue and remove it from the queue. If the queue is empty, print "V".
Q End the program execution. Print "the end".
You can assume the following when implementing the program:
1. All the integers are between -1000000 - +1000000
2. The input lines are at best 75 characters long
3. No undefined commands are given. All commands and their elements are separated with one or more white space character (space, tab stop, newline).
Thanx for the help
Thanx.
Implement a FIFO-queue ( first in, first out ) as a ring buffer. Use a static array as the data structure. The program needs to be able to add elements to the end of the queue, tell the value of the oldest element and remove from the queue. The capacity n of the ring buffer is 10000 elements.
The program must handle the following commands:
L k Read in an integer k, push it to the end of the queue and print "L". If the queue is already full, just print an error message "V".
T Print the value of the oldest element in the queue. If the queue is empty, print "V".
P Print the value of the oldest element in the queue and remove it from the queue. If the queue is empty, print "V".
Q End the program execution. Print "the end".
You can assume the following when implementing the program:
1. All the integers are between -1000000 - +1000000
2. The input lines are at best 75 characters long
3. No undefined commands are given. All commands and their elements are separated with one or more white space character (space, tab stop, newline).
Thanx for the help
Comment