Advertisement
OldBeliver

Collection_02ver01

Apr 2nd, 2021
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace WaitingLine_ver01
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int balance = 0;
  14.  
  15.             Queue<int> bills = GetBills();
  16.  
  17.             Console.Write($"сгенерированное множество чеков:");
  18.            
  19.             foreach (int bill in bills)
  20.             {
  21.                 Console.Write($" {bill},");
  22.             }
  23.             Console.WriteLine($"\b.");
  24.  
  25.             while (bills.Count > 0)
  26.             {
  27.                 Console.WriteLine($"Количество клиентов в очереди {bills.Count}");                
  28.  
  29.                 Console.WriteLine($"\nПеред Вами клиент с чеком на {bills.Peek()}");
  30.                 Console.WriteLine($"Обслужить клиента");
  31.                 Console.ReadKey();
  32.  
  33.                 balance += bills.Dequeue();
  34.                 Console.Clear();
  35.  
  36.                 Console.WriteLine($"Сумма чеков: {balance}");
  37.             }
  38.             Console.ReadKey();
  39.         }
  40.  
  41.         static Queue<int> GetBills()
  42.         {
  43.             Random rand = new Random();
  44.  
  45.             int minimumBill = 10;
  46.             int maximumBill = 100;
  47.             int size = 10;
  48.  
  49.             Queue<int> bills = new Queue<int>();
  50.  
  51.             for (int i = 0; i < size; i++)
  52.             {
  53.                 bills.Enqueue(rand.Next(minimumBill, maximumBill + 1));
  54.             }
  55.  
  56.             return bills;
  57.         }
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement