Advertisement
silvana1303

last stop

Jun 17th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<string> numbers = Console.ReadLine().Split().ToList();
  14.  
  15.             string[] command = Console.ReadLine().Split().ToArray();
  16.  
  17.             while (command[0] != "END")
  18.             {
  19.                 if (command[0] == "Change")
  20.                 {
  21.                     if (numbers.Contains(command[1]))
  22.                     {
  23.                         int index = numbers.IndexOf(command[1]);
  24.                         numbers[index] = command[2];
  25.                     }
  26.                 }
  27.                 if (command[0] == "Hide")
  28.                 {
  29.                     if (numbers.Contains(command[1]))
  30.                     {
  31.                         numbers.Remove(command[1]);
  32.                     }
  33.                 }
  34.                 if (command[0] == "Switch")
  35.                 {
  36.                     if (numbers.Contains(command[1]) && numbers.Contains(command[2]))
  37.                     {
  38.                         int index1 = numbers.IndexOf(command[1]);
  39.                         int index2 = numbers.IndexOf(command[2]);
  40.  
  41.                         numbers[index1] = command[2];
  42.                         numbers[index2] = command[1];
  43.                     }
  44.                 }
  45.                 if (command[0] == "Insert")
  46.                 {
  47.                     int index = int.Parse(command[1]) + 1;
  48.  
  49.                     if (index >= 0 && index < numbers.Count)
  50.                     {
  51.                         numbers.Insert(index, command[2]);
  52.                     }
  53.                 }
  54.                 if (command[0] == "Reverse")
  55.                 {
  56.                     numbers.Reverse();
  57.                 }
  58.  
  59.                 command = Console.ReadLine().Split().ToArray();
  60.             }
  61.  
  62.             Console.WriteLine(string.Join(" ",numbers));
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement