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 Problem_2.Anonymous_Threat
- {
- class paramsInput
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- //string[] paramsInput = input.Split(' ');
- List<string> paramsInput = input.Split(' ').ToList();
- List<string> result = new List<string>();
- string command = Console.ReadLine();
- while(command != "3:1")
- {
- string[] commandParams = command.Split(' ');
- string commandName = commandParams[0];
- int startIndex = int.Parse(commandParams[1]);
- int endIndex = int.Parse(commandParams[2]);
- //If any of the given indexes is out of the array, you must take ONLY the range that is INSIDE the array and merge it.
- if(startIndex < 0)
- {
- startIndex = 0;
- }
- if(startIndex > paramsInput.Count())
- {
- startIndex = paramsInput.Count();
- }
- if (endIndex < 0)
- {
- endIndex = 0;
- }
- if (endIndex > paramsInput.Count())
- {
- endIndex = paramsInput.Count();
- }
- // LOGIC
- switch (commandName)
- {
- case "merge":
- string resultWord = string.Empty;
- for (int i = startIndex; i < endIndex+1; i++)
- {
- resultWord += paramsInput[i];
- }
- paramsInput.RemoveRange(startIndex, endIndex+1);
- paramsInput.Insert(startIndex, resultWord);
- // Console.WriteLine(resultWord);
- Console.WriteLine(string.Join(" ", paramsInput));
- break;
- case "divide":
- break;
- default:
- Console.WriteLine("da go lapate");
- return;
- }
- command = Console.ReadLine();
- }
- // print
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement