Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _2._ChangeList
- {
- class ChangeList
- {
- static void Main()
- {
- List<int> numbers = Console.ReadLine()
- .Split(" ")
- .Select(int.Parse)
- .ToList();
- string input;
- while ((input = Console.ReadLine()) != "end")
- {
- string[] splitedInput = input
- .Split(" ");
- string command = splitedInput[0];
- int number = int.Parse(splitedInput[1]);
- if (command == "Delete")
- {
- //numbers.RemoveAll(x => x == number);
- for (int i = 0; i < numbers.Count; i++)
- {
- if (number == numbers[i])
- {
- numbers.Remove(number);
- i--;
- }
- }
- }
- else if (command == "Insert")
- {
- int position = int.Parse(splitedInput[2]);
- numbers.Insert(position, number);
- }
- }
- Console.WriteLine(string.Join(" ", numbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement