veno0

Untitled

Feb 14th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp6
  6. {
  7.     class Program
  8.     {
  9.        
  10.         static void Main(string[] args)
  11.         {
  12.             // read list of integers
  13.             List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
  14.             while (true)
  15.             {
  16.  
  17.                 List<string> command = Console.ReadLine().Split().ToList();
  18.                 if (command[0] == "end")
  19.                 {
  20.                     break;
  21.                 }
  22.  
  23.                 if (command[0] == "Add")
  24.                 {
  25.                     numbers.Add(int.Parse(command[1]));
  26.                 }
  27.                 else if (command[0] == "Insert")
  28.                 {
  29.                     numbers.Insert(int.Parse(command[2]), int.Parse(command[1]));
  30.                 }
  31.                 else if (command[0] == "Remove")
  32.                 {
  33.                     numbers.RemoveAt(int.Parse(command[1]));
  34.                 }
  35.                
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment