Facebook
From da, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 58
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02.Commands
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> list = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
  12.  
  13.             string input = Console.ReadLine();
  14.  
  15.             while (input != "end")
  16.             {
  17.                 string[] commands = input.Split();
  18.                 string command = commands[0];
  19.                 if (commands[0] == "reverse")
  20.                 {
  21.                     int index = int.Parse(commands[2]);
  22.                     int secondIndex = int.Parse(commands[4]) + index - 2;
  23.                     list.Reverse(index, secondIndex);
  24.                 }
  25.                 else if (commands[0] == "sort")
  26.                 {
  27.                     int index = int.Parse(commands[2]);
  28.                     int secondIndex = int.Parse(commands[4]) + index - 2;
  29.                     list.Sort(index, secondIndex, Comparer<int>.Default);
  30.                 }
  31.                 else if (commands[0] == "remove")
  32.                 {
  33.                     int index = int.Parse(commands[1]);
  34.                     list.RemoveRange(0, index);                    
  35.                 }
  36.  
  37.                 input = Console.ReadLine();
  38.             }
  39.  
  40.             Console.WriteLine(String.Join(", ", list));
  41.         }
  42.     }
  43. }
  44.