Skip to content

Instantly share code, notes, and snippets.

@kyzalex
Created April 22, 2024 18:43
Show Gist options
  • Save kyzalex/110b203b74aef441daadcc0f2df5f124 to your computer and use it in GitHub Desktop.
Save kyzalex/110b203b74aef441daadcc0f2df5f124 to your computer and use it in GitHub Desktop.
Очередь в магазине
internal class Program
{
static void Main(string[] args)
{
int moneyInVallet = 0;
int numberOfPeople = 10;
int minRandom = 10;
int maxRandom = 100;
Random random = new Random();
Queue<int> peoples = new Queue<int>();
for (int i = 0; i < numberOfPeople; i++)
{
int randomCost = random.Next(minRandom, maxRandom);
peoples.Enqueue(randomCost);
}
while (peoples.Count > 0)
{
Console.WriteLine($"Денег в кошельке: {moneyInVallet} рублей");
Console.WriteLine($"\nНажмите любую кнопку, чтобы обслужить клиента на сумму в {peoples.Peek()}...");
Console.WriteLine("\nДеньги у клиентов в очереди:");
foreach (int people in peoples)
{
Console.WriteLine($"{people} рублей");
}
Console.ReadKey();
moneyInVallet += peoples.Dequeue();
Console.Clear();
}
Console.WriteLine($"У вас в кошельке {moneyInVallet}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment