← Back to STL Containers
Question 490
Ticket Line Simulation
Ticket Line Simulation
Simulate a ticket line with aqueue<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 everyservecommand print exactly one line:Serving NAME(for exampleServing Bob) if someone is waiting, orNobody waitingif 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 — 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.