Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp7
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> inputList = Console.ReadLine().Split().Select(int.Parse).ToList();
- string command = Console.ReadLine();
- while (command != "Odd" && command != "Even")
- {
- string[] tokens = command.Split();
- if (tokens[0] == "Delete")
- {
- int deleteNum = int.Parse(tokens[1]);
- inputList.RemoveAll(item => item == deleteNum);
- }
- else if (tokens[0] == "Insert")
- {
- int element = int.Parse(tokens[1]);
- int index = int.Parse(tokens[2]);
- inputList.Insert(index, element);
- }
- command = Console.ReadLine();
- }
- if (command == "Odd")
- {
- for (int i = 0; i < inputList.Count; i++)
- {
- if (inputList[i] % 2 != 0)
- {
- Console.Write(inputList[i] + " ");
- }
- }
- }
- else if (command == "Even")
- {
- for (int i = 0; i < inputList.Count; i++)
- {
- if (inputList[i] % 2 == 0)
- {
- Console.Write(inputList[i] + " ");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement