Created
April 22, 2025 16:45
-
-
Save negurin/0ab4a258ebc7c9c1e9327838ea7af0c5 to your computer and use it in GitHub Desktop.
ijHomework
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
namespace Queue | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Queue<int> purchasesAmounts = new Queue<int>(); | |
purchasesAmounts.Enqueue(500); | |
purchasesAmounts.Enqueue(1500); | |
purchasesAmounts.Enqueue(25250); | |
purchasesAmounts.Enqueue(9500); | |
purchasesAmounts.Enqueue(700); | |
purchasesAmounts.Enqueue(12000); | |
purchasesAmounts.Enqueue(8000); | |
purchasesAmounts.Enqueue(6500); | |
int shopAccount = 0; | |
ConsoleKey serveKey = ConsoleKey.Enter; | |
while (purchasesAmounts.Count > 0) | |
{ | |
Console.Write("Клиентов в очереди: " + purchasesAmounts.Count + "\n"); | |
Console.Write($"Деньги в кассе: {shopAccount}\n"); | |
Console.WriteLine("Ослуживание клиента с суммой покупки = " + purchasesAmounts.Peek()); | |
Console.WriteLine("\nЧтобы обслужить клиента нажмите клавишу Enter"); | |
if (Console.ReadKey().Key == serveKey) | |
{ | |
shopAccount += purchasesAmounts.Dequeue(); | |
Console.WriteLine("Клиент обслужен!"); | |
} | |
else | |
{ | |
Console.WriteLine("Неверный ввод! Пожалуйста, повторите попытку!"); | |
} | |
ShowPressAnyKeyMessage(); | |
} | |
Console.WriteLine("Все клиенты были обслужены. Хорошая работа!"); | |
Console.WriteLine($"Заработано денег: {shopAccount}"); | |
ShowPressAnyKeyMessage(); | |
} | |
static void ShowPressAnyKeyMessage() | |
{ | |
Console.WriteLine("\nДля продолжения нажмите любую клавишу..."); | |
Console.ReadKey(); | |
Console.Clear(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment