Skip to content

Instantly share code, notes, and snippets.

@StrikerXx798
Created April 20, 2025 10:20
Show Gist options
  • Save StrikerXx798/5bfde1ca64f743229b5b7fdc6e12ed8e to your computer and use it in GitHub Desktop.
Save StrikerXx798/5bfde1ca64f743229b5b7fdc6e12ed8e to your computer and use it in GitHub Desktop.
ДЗ: Очередь в магазине
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode;
Queue<int> clients = new Queue<int>(new int[] { 100, 200, 300, 400, 500 });
int accountBalance = 0;
while (clients.Count > 0)
{
Console.Clear();
Console.WriteLine($"Текущий баланс: {accountBalance} руб.");
Console.WriteLine($"Сумма покупки клиента: {clients.Peek()} руб.");
Console.WriteLine("Нажмите любую клавишу для обслуживания клиента...");
Console.ReadKey(true);
accountBalance += clients.Dequeue();
}
Console.Clear();
Console.WriteLine($"Все клиенты обслужены. Итоговый баланс: {accountBalance} руб.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment