Ticket Line Simulation
mediumQuestion 490Simulate a ticket line with a queue<string>. Read commands from standard input, one per line, until the input ends. There are two kinds of command:
arrive NAME - the person NAME joins the back of the line (prints nothing) serve - the person at the front of the line is served and leaves
For every serve command print exactly one line: Serving NAME (for example Serving Bob) if someone is waiting, or Nobody waiting if the line is empty.
Example input: arrive Bob serve serve
The output for that input is shown in Expected Output.
Expected output
Serving Bob Nobody waiting Serving Ann Serving Cara Serving Dan Nobody waiting
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
STL ContainersQueues
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.