Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Soft
- {
- public static void Main()
- {
- List<int> nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- List<string> command = new List<string>(3);
- do
- {
- command = Console.ReadLine().Split(' ').ToList();
- switch (command[0])
- {
- case "add":
- {
- nums.Insert(int.Parse(command[1]), int.Parse(command[2]));
- break;
- }
- case "addMany":
- {
- nums.InsertRange(int.Parse(command[1]), command.Skip(2).Select(int.Parse).ToArray());
- break;
- }
- case "contains":
- {
- Console.WriteLine(nums.IndexOf(int.Parse(command[1])));
- break;
- }
- case "remove":
- {
- nums.RemoveAt(int.Parse(command[1]));
- break;
- }
- case "shift":
- {
- int shiftCycles = int.Parse(command[1]);
- while(shiftCycles>0)
- {
- int first = nums[0];
- nums.RemoveAt(0);
- nums.Add(first);
- shiftCycles--;
- }
- break;
- }
- case "sumPairs":
- {
- for(int i=0;i<nums.Count-1;i++)
- {
- nums[i] = nums[i] + nums[i + 1];
- nums.RemoveAt(i + 1);
- }
- break;
- }
- }
- }
- while (command[0] != "print");
- Console.WriteLine($"[{string.Join(", ", nums)}]");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement