Supermarket
using System;
using System.Collections.Generic;
using System.Linq;
namespace Supermarket
{
class Program
{
static void Main(string[] args)
{
string input = Console.ReadLine();
var quue = new Queue<string>();
int counter = 0;
string[] array = { " " };
while (true)
{
quue.Enqueue(input);
input = Console.ReadLine();
counter++;
if (input == "Paid")
{
array = quue.ToArray();
quue.Clear();
}
else if (input=="End")
{
break;
}
}
for (int i = 0; i < quue.Count; i++)
{
Console.WriteLine(array[i]);
}
Console.WriteLine($"{counter} people remaining");
}
}
}
Ако може някой да го редактира ще ми свърши голяма услуга понеже аз не се сещам как трябва да стане.
Reads an input consisting of a name and adds it to a queue until "End" is received. If you receive "Paid", print every customer name and empty the queue, otherwise we receive a client and we have to add him to the queue. When we receive "End" we have to print the count of the remaining people in the queue in the format: "{count} people remaining.".
Examples
Input |
Output |
Gosho Pesho Ivan Paid Nasko Stefan Naska Tanq End |
Gosho Pesho Ivan 4 people remaining. |
Ani Miro Stoyan End |
3 people remaining. |