silvana1303

supermarket

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