lovelyvook

Unit_33

Jul 3rd, 2024 (edited)
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Ijunior
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Queue<int> customers = new Queue<int>();
  11.             int sum = 0;
  12.             int offsetInfo = 40;
  13.             int currenCustomer;
  14.  
  15.             FillQueue(customers);
  16.  
  17.             while (customers.Count > 0)
  18.             {
  19.                 currenCustomer = customers.Dequeue();
  20.                 sum += currenCustomer;
  21.  
  22.                 Console.SetCursorPosition(0, 0);
  23.                 Console.WriteLine("Текущий покупатель: " + currenCustomer);
  24.  
  25.                 foreach (var customer in customers)
  26.                 {
  27.                     Console.WriteLine(customer);
  28.                 }
  29.  
  30.                 Console.SetCursorPosition(offsetInfo, 0);
  31.                 Console.WriteLine("Общая сумма: " + sum);
  32.                 Console.ReadKey();
  33.                 Console.Clear();
  34.             }
  35.         }
  36.  
  37.         static void FillQueue(Queue<int> queue)
  38.         {
  39.             Random random = new Random();
  40.             int minRandomNumber = 10;
  41.             int maxRandomNumber = 100;
  42.             int countCustomers = 10;
  43.  
  44.             for (int i = 0; i < countCustomers; i++)
  45.             {
  46.                 queue.Enqueue(random.Next(minRandomNumber, maxRandomNumber));
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment