Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace arrayManipulator
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> input = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToList();
- List<int> contains = new List<int>();
- List<int> addMany = new List<int>();
- while (true)
- {
- List<string> operations = Console.ReadLine()
- .Split()
- .ToList();
- if (operations[0] == "add")
- {
- input.Insert(int.Parse(operations[1]), int.Parse(operations[2]));
- }
- else if (operations[0] == "addMany")
- {
- for (int i = 2; i < operations.Count; i++)
- {
- addMany.Add(int.Parse(operations[i]));
- }
- input.InsertRange(int.Parse(operations[1]), addMany);
- }
- else if (operations[0] == "contains")
- {
- Console.WriteLine(input.IndexOf(int.Parse(operations[1])));
- }
- else if (operations[0] == "remove")
- {
- input.RemoveAt(int.Parse(operations[1]));
- }
- else if (operations[0] == "shift")
- {
- int first = input[0];
- input.RemoveAt(0);
- input.Add(first);
- }
- else if(operations[0] == "sumPairs")
- {
- for (int i = 0; i < input.Count - 1; i++)
- {
- input[i] += input[i + 1];
- input.RemoveAt(i + 1);
- }
- }
- else if (operations[0] == "print")
- {
- break;
- }
- }
- Console.WriteLine($"[{string.Join(", ", input)}]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement