Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ChangeList
- {
- class Program
- {
- static void Main(string[] args)
- {
- var sequence = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- while (true)
- {
- var commands = Console.ReadLine().Split(' ').ToList();
- if (commands[0] == "Delete")
- {
- var dell = Convert.ToInt64(commands[1]);
- sequence.RemoveAll(x => x == dell);
- }
- if (commands[0] == "Insert")
- {
- var number = Convert.ToInt32(commands[1]);
- var position = Convert.ToInt32(commands[2]);
- sequence.Insert(position, number);
- }
- if (commands[0] == "Even")
- {
- var printEven = sequence.Where(x => x % 2 == 0);
- Console.WriteLine(string.Join(" ", printEven));
- break;
- }
- else if (commands[0] == "Odd")
- {
- var printOdd = sequence.Where(x => x % 2 != 0);
- Console.WriteLine(string.Join(" ", printOdd));
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement