Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace QueuesAndStacks
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] inputSongs = Console.ReadLine().Split(", ").ToArray();
- Queue<string> songsQueue = new Queue<string>();
- string[] comanda = Console.ReadLine().Split(" ").ToArray();
- for (int i = 0; i < inputSongs.Length; i++)
- {
- songsQueue.Enqueue(inputSongs[i]);
- }
- while (songsQueue.Any())
- {
- if (comanda[0] == "Play")
- {
- songsQueue.Dequeue();
- }
- else if (comanda[0] == "Add")
- {
- string[] songName = new string[comanda.Length - 1];
- for (int i = 0; i < songName.Length; i++)
- {
- songName[i] = comanda[i + 1];
- }
- string songFullname = string.Join(" ",songName);
- if (songsQueue.Contains(songFullname))
- {
- Console.WriteLine($"{songFullname} is already contained! ");
- }
- else
- {
- songsQueue.Enqueue(songFullname);
- }
- }
- else if (comanda[0] == "Show")
- {
- Console.WriteLine("{0}", string.Join(", ", songsQueue));
- }
- comanda = Console.ReadLine().Split(" ").ToArray();
- }
- if (!songsQueue.Any())
- {
- Console.WriteLine("No more songs!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement