nikitaTheSlayer

Lesson: Queue

Oct 22nd, 2021 (edited)
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Collections
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Queue<int> clients = new Queue<int>();
  11.             int balance = 0;
  12.  
  13.             clients.Enqueue(5);
  14.             clients.Enqueue(7);
  15.             clients.Enqueue(6);
  16.             clients.Enqueue(12);
  17.             clients.Enqueue(9);
  18.             clients.Enqueue(8);
  19.             clients.Enqueue(10);
  20.  
  21.             while (clients.Count > 0)
  22.             {
  23.                 Console.WriteLine($"Баланс равен {balance} рублей");
  24.                 Console.ReadLine();
  25.                 Console.Clear();
  26.                 Console.WriteLine($"Клиент обслужен, баланс пополнился на {clients.Peek()} рублей");
  27.                 balance += clients.Dequeue();
  28.             }
  29.         }
  30.     }
  31. }
  32.  
Add Comment
Please, Sign In to add comment