Advertisement
silvana1303

change list

Jun 3rd, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5. using System.Text;
  6.  
  7. namespace exampreparation
  8. {
  9.     class exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> list = Console.ReadLine().Split().Select(int.Parse).ToList();
  14.  
  15.             List<string> input = Console.ReadLine().Split().ToList();
  16.  
  17.             while (input[0] != "end")
  18.             {
  19.                 if (input.Count == 2)
  20.                 {
  21.                     int number = int.Parse(input[1]);
  22.                     list.RemoveAll(item => item == number);
  23.                 }
  24.                 else
  25.                 {
  26.                     int index = int.Parse(input[2]);
  27.                     int element = int.Parse(input[1]);
  28.                     list.Insert(index, element);
  29.                 }
  30.  
  31.                 input = Console.ReadLine().Split().ToList();
  32.             }
  33.  
  34.             Console.WriteLine(string.Join(" ", list));
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement