radostina92

Commands

Nov 8th, 2020 (edited)
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02.Zadacha
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<string> num = Console.ReadLine()
  12.                 .Split()
  13.                 .ToList();
  14.  
  15.             string command = string.Empty;
  16.  
  17.             while ((command = Console.ReadLine()) != "end")
  18.             {
  19.                 string[] arguments = command.Split();
  20.  
  21.                 string name = arguments[0];
  22.  
  23.                 if (name == "reverse")
  24.                 {
  25.                     int index = int.Parse(arguments[2]);
  26.                     int count = int.Parse(arguments[4]);
  27.  
  28.                     num.Reverse(index, count);
  29.                 }
  30.                 else if (name == "sort")
  31.                 {
  32.                     int index = int.Parse(arguments[2]);
  33.                     int count = int.Parse(arguments[4]);
  34.                     num.Sort(index, count, StringComparer.Ordinal);
  35.                 }
  36.                 else if (name == "remove")
  37.                 {
  38.                     int index = int.Parse(arguments[1]);
  39.                     num.RemoveRange(0, index);
  40.  
  41.                 }
  42.             }
  43.             Console.WriteLine(string.Join(", ", num));
  44.         }
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment