Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Security.Principal;
- namespace Очередь_в_магазине
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int maxQueueMembers = 10;
- int bankAccount = 0;
- Queue<int> clients = new Queue<int>(maxQueueMembers);
- Random random = new Random();
- FillQueue(clients, random, maxQueueMembers);
- ServeBankAccount(clients, bankAccount);
- }
- static void FillQueue(Queue<int> clients, Random random, int maxQueueMembers)
- {
- int minBill = 1;
- int maxBill = 1000;
- for (int i = 0; i < maxQueueMembers; i++)
- {
- clients.Enqueue(random.Next(minBill, maxBill));
- }
- }
- static void ServeBankAccount(Queue<int> clients, int bankAccount)
- {
- while (clients.Count > 0)
- {
- int bill = clients.Dequeue();
- bankAccount += bill;
- Console.WriteLine($"Сумма покупки {bill};");
- Console.WriteLine($"На банковском счете сейчас {bankAccount}");
- Console.ReadKey();
- Console.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement