using System; using System.Collections.Generic; using System.Linq; namespace Lab1RemoveNegatxvesAndReverse { class Program { public static List nums = new List(); static void Main(string[] args) { //Console.WriteLine(5 % 3); nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList(); string[] command = Console.ReadLine().Split(' ').ToArray(); while (command[0] != "print") { switch (command[0]) { case "add": nums.Insert(int.Parse(command[1]), int.Parse(command[2])); break; case "addMany": int pos = int.Parse(command[1]); for (int i = 2; i < command.Length; i++) { nums.Insert(pos, int.Parse(command[i])); pos++; } break; case "contains": int index = nums.IndexOf(int.Parse(command[1])); Console.WriteLine(index); break; case "remove": nums.RemoveAt(int.Parse(command[1])); break; case "shift": int positions = int.Parse(command[1]) % nums.Count; List moved = new List(); for (int i = 0; i < positions; i++) { moved.Add(nums[0]); nums.RemoveAt(0); } nums.AddRange(moved); //for (int i = 0; i < positions; i++) //{ // nums.Add(moved[i]); //} break; case "sumPairs": for (int i = 0; i < nums.Count - nums.Count % 2; i += 2) { nums[i] += nums[i + 1]; nums[i + 1] = -1; } nums.RemoveAll(x => x == -1); break; default: Console.WriteLine("Incorrect input. Please write add, addMany, contains, shift or sumPairs"); break; } command = Console.ReadLine().Split(' ').ToArray(); } Console.WriteLine("[" + string.Join(", ", nums) + "]"); } } }