Advertisement
EmoRz

ChangeList

May 30th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ChangeList
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var sequence  = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  11.            
  12.             while (true)
  13.             {
  14.                 var commands = Console.ReadLine().Split(' ').ToList();
  15.                 if (commands[0] == "Delete")
  16.                 {
  17.                     var dell = Convert.ToInt64(commands[1]);
  18.                     sequence.RemoveAll(x => x == dell);
  19.                 }
  20.                 if (commands[0] == "Insert")
  21.                 {
  22.                     var number = Convert.ToInt32(commands[1]);
  23.                     var position = Convert.ToInt32(commands[2]);
  24.                     sequence.Insert(position, number);
  25.                 }
  26.                 if (commands[0] == "Even")
  27.                 {
  28.                     var printEven = sequence.Where(x => x % 2 == 0);
  29.                     Console.WriteLine(string.Join(" ", printEven));
  30.                     break;
  31.                 }
  32.                 else if (commands[0] == "Odd")
  33.                 {
  34.                     var printOdd = sequence.Where(x => x % 2 != 0);
  35.                     Console.WriteLine(string.Join(" ", printOdd));
  36.                     break;
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement