Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace WaitingLine_ver01
- {
- class Program
- {
- static void Main(string[] args)
- {
- int balance = 0;
- Queue<int> bills = GetBills();
- Console.Write($"сгенерированное множество чеков:");
- foreach (int bill in bills)
- {
- Console.Write($" {bill},");
- }
- Console.WriteLine($"\b.");
- while (bills.Count > 0)
- {
- Console.WriteLine($"Количество клиентов в очереди {bills.Count}");
- Console.WriteLine($"\nПеред Вами клиент с чеком на {bills.Peek()}");
- Console.WriteLine($"Обслужить клиента");
- Console.ReadKey();
- balance += bills.Dequeue();
- Console.Clear();
- Console.WriteLine($"Сумма чеков: {balance}");
- }
- Console.ReadKey();
- }
- static Queue<int> GetBills()
- {
- Random rand = new Random();
- int minimumBill = 10;
- int maximumBill = 100;
- int size = 10;
- Queue<int> bills = new Queue<int>();
- for (int i = 0; i < size; i++)
- {
- bills.Enqueue(rand.Next(minimumBill, maximumBill + 1));
- }
- return bills;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement