Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace СSharpLigth_HomeWork___Queue
- {
- class Program
- {
- static void Main(string[] args)
- {
- int cash = 134;
- Queue<int> buyers = new Queue<int>();
- buyers.Enqueue(512);
- buyers.Enqueue(1024);
- buyers.Enqueue(718);
- buyers.Enqueue(541);
- buyers.Enqueue(51);
- while (buyers.Count > 0)
- {
- ShowCash(cash);
- ShowCountQueue(buyers.Count);
- var bayer = buyers.Dequeue();
- Console.WriteLine($"Сумма покупки - {bayer} руб.");
- cash += bayer;
- Console.ReadKey();
- Console.Clear();
- }
- Console.WriteLine("В очереди больше нет людей.");
- ShowCash(cash);
- Console.ReadKey();
- }
- public static void ShowCash(int cash)
- {
- Console.WriteLine($"В кассе {cash} рублей.");
- }
- public static void ShowCountQueue(int count)
- {
- if (count > 1 && count < 5)
- {
- Console.WriteLine($"В очереди сейчас {count} человека.");
- }
- else
- {
- Console.WriteLine($"В очереди сейчас {count} человек.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment