Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp3
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Queue<int> clientsQueue = new Queue<int>();
- CreateQueue(clientsQueue);
- ServQueue(clientsQueue);
- }
- static void CreateQueue(Queue<int> clientsQueue)
- {
- int numberClients = 10;
- int maxValue = 21;
- int minValue = 10;
- Random random = new Random();
- for (int i = 0; i < numberClients; i++)
- clientsQueue.Enqueue(random.Next(minValue, maxValue));
- }
- static void PrintQueue(Queue<int> clientsQueue)
- {
- Console.Write("Очередь клиентов: ");
- foreach (var client in clientsQueue)
- Console.Write(client + " ");
- Console.WriteLine();
- }
- static void ServQueue(Queue<int> clientsQueue)
- {
- int totalCost = 0;
- while (clientsQueue.Count > 0)
- {
- PrintQueue(clientsQueue);
- Console.WriteLine("текущая стоимость покупок: " + totalCost);
- totalCost += clientsQueue.Peek();
- Console.WriteLine("следующая покупка: " + clientsQueue.Dequeue());
- Console.ReadKey();
- Console.Clear();
- }
- Console.WriteLine("полная стоимость покупок: " + totalCost);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement