CJCoding With Joseph
15free / daySign inCreate account

Ticket Line Simulation

Simulate 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 — print one after the last line.

Hints4 available
Topics:
STL ContainersQueues
📥 Auto-Input:
arrive Bob\nserve\nserve\n
This input is automatically fed to your program's stdin
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.