Advertisement
gabi11

Stacks and Queues - 5. Supermarket

May 10th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. namespace Advanced
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             var customers = new Queue<string>();
  13.  
  14.             while (true)
  15.             {
  16.                 string input = Console.ReadLine();
  17.  
  18.                 if (input == "End")
  19.                 {
  20.                     break;
  21.                 }
  22.  
  23.                 if (input == "Paid")
  24.                 {
  25.                     while (customers.Count != 0)
  26.                     {
  27.                         Console.WriteLine(customers.Dequeue());
  28.                     }
  29.                 }
  30.  
  31.                 else
  32.                 {
  33.                     customers.Enqueue(input);
  34.                 }
  35.             }
  36.  
  37.             Console.WriteLine($"{customers.Count} people remaining.");
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement