Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace CSLight
- {
- internal class Program
- {
- static void Main()
- {
- Queue<int> clients = new Queue<int>();
- int totalAmount = 0;
- DeclareQueue(clients);
- while (clients.Count != 0)
- {
- ServeQueue(clients, ref totalAmount);
- Console.ReadKey();
- Console.Clear();
- }
- Console.Write("Очередь пуста. Итоговая общая сумма: " + totalAmount + "\n");
- }
- static Queue<int> DeclareQueue(Queue<int> clients)
- {
- int clientsInQueue = 5;
- int minValue = 10;
- int maxValue = 50;
- Random random = new Random();
- for (int i = 0; i < clientsInQueue; i++)
- {
- clients.Enqueue(random.Next(minValue, maxValue));
- }
- return clients;
- }
- static void ServeQueue(Queue<int> clients, ref int totalAmount)
- {
- Console.Write("Сумма покупки: " + clients.Peek());
- Console.Write("\n\nОбщая сумма: " + totalAmount);
- totalAmount += clients.Dequeue();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement