Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _03.TheFinalQuest
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<string> message = Console.ReadLine().Split().ToList();
  12.             string[] command = Console.ReadLine().Split();
  13.             while (command[0] != "Stop")
  14.             {
  15.                 if (command[0] == "Delete")
  16.                 {
  17.                     if (int.Parse(command[1]) <= message.Count)
  18.                     {
  19.                         message.RemoveAt(int.Parse(command[1]) + 1);
  20.                     }
  21.                 }
  22.                 else if (command[0] == "Swap")
  23.                 {
  24.                     if (message.Contains(command[1]) && message.Contains(command[2]))
  25.                     {
  26.                         for (int i = 0; i < message.Count; i++)
  27.                         {
  28.                             if (command[1] == message[i])
  29.                             {
  30.                                 message.Remove(command[1]);
  31.                                 message.Insert(i, command[2]);
  32.                             }
  33.                             else if (command[2] == message[i])
  34.                             {
  35.                                 message.Remove(command[2]);
  36.                                 message.Insert(i, command[1]);
  37.                             }
  38.                         }
  39.                     }
  40.                 }
  41.                 else if (command[0] == "Put")
  42.                 {
  43.                     if (int.Parse(command[2]) <= message.Count)
  44.                     {
  45.                         message.Insert(int.Parse(command[2]) - 1, command[1]);
  46.                     }
  47.                 }
  48.                 else if (command[0] == "Sort")
  49.                 {
  50.  
  51.                 }
  52.                 else
  53.                 {
  54.                     for (int i = 0; i < message.Count; i++)
  55.                     {
  56.                         if (message[i] == command[2])
  57.                         {
  58.                             message.Remove(command[2]);
  59.                             message.Insert(i, command[1]);
  60.                         }
  61.                     }
  62.                 }
  63.                 command = Console.ReadLine().Split();
  64.             }
  65.             Console.WriteLine(string.Join(" ",message));
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement