Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03.TheFinalQuest
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> message = Console.ReadLine().Split().ToList();
- string[] command = Console.ReadLine().Split();
- while (command[0] != "Stop")
- {
- if (command[0] == "Delete")
- {
- if (int.Parse(command[1]) <= message.Count)
- {
- message.RemoveAt(int.Parse(command[1]) + 1);
- }
- }
- else if (command[0] == "Swap")
- {
- if (message.Contains(command[1]) && message.Contains(command[2]))
- {
- for (int i = 0; i < message.Count; i++)
- {
- if (command[1] == message[i])
- {
- message.Remove(command[1]);
- message.Insert(i, command[2]);
- }
- else if (command[2] == message[i])
- {
- message.Remove(command[2]);
- message.Insert(i, command[1]);
- }
- }
- }
- }
- else if (command[0] == "Put")
- {
- if (int.Parse(command[2]) <= message.Count)
- {
- message.Insert(int.Parse(command[2]) - 1, command[1]);
- }
- }
- else if (command[0] == "Sort")
- {
- }
- else
- {
- for (int i = 0; i < message.Count; i++)
- {
- if (message[i] == command[2])
- {
- message.Remove(command[2]);
- message.Insert(i, command[1]);
- }
- }
- }
- command = Console.ReadLine().Split();
- }
- Console.WriteLine(string.Join(" ",message));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement