Created
April 22, 2024 18:43
-
-
Save kyzalex/110b203b74aef441daadcc0f2df5f124 to your computer and use it in GitHub Desktop.
Очередь в магазине
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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