Created
April 24, 2025 18:50
-
-
Save vohahudozhnik/0de96b1ef4e7f6fab10595a6e8f50270 to your computer and use it in GitHub Desktop.
ДЗ: Очередь в магазине 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Training1 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Queue<int> purchaseAmount = new Queue<int>(); | |
purchaseAmount.Enqueue(1); | |
purchaseAmount.Enqueue(2); | |
purchaseAmount.Enqueue(6); | |
purchaseAmount.Enqueue(7); | |
purchaseAmount.Enqueue(8); | |
purchaseAmount.Enqueue(4); | |
int money = 0; | |
while (purchaseAmount.Count > 0) | |
{ | |
ShowQueue( purchaseAmount, ref money); | |
ServeQueue( purchaseAmount, ref money); | |
} | |
} | |
static void FillCashRegister (Queue<int> purchaseAmount, ref int money) | |
{ | |
money += purchaseAmount.Dequeue(); | |
Console.WriteLine("Денег в кассе - " + money); | |
} | |
static void ShowQueue(Queue<int> purchaseAmount, ref int money) | |
{ | |
Console.SetCursorPosition(0,0); | |
Console.Write("Очередь - "); | |
foreach (var purchase in purchaseAmount) | |
{ | |
Console.Write(purchase + " "); | |
} | |
} | |
static void ServeQueue(Queue<int> purchaseAmount, ref int money) | |
{ | |
Console.ReadKey(); | |
Console.Clear(); | |
Console.SetCursorPosition(0,1); | |
FillCashRegister( purchaseAmount,ref money); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment