Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _01._World_Tour
- {
- class Program
- {
- static void Main(string[] args)
- {
- string firstInput = Console.ReadLine();
- while (true)
- {
- string input = Console.ReadLine();
- if (input != "Travel")
- {
- List<string> listInput = input.Split(':').ToList();
- string command = listInput[0];
- string index = listInput[1];
- string addString = listInput[2];
- if (command == "Add Stop" && int.Parse(index) >=0 && int.Parse(index) < firstInput.Length)
- {
- firstInput = firstInput.Insert(int.Parse(index), addString);
- Console.WriteLine(firstInput);
- }
- else if (command == "Remove Stop" && int.Parse(index) >= 0 && int.Parse(index) < firstInput.Length
- && int.Parse(addString) >= 0 && int.Parse(addString) < firstInput.Length)
- {
- int removeCount = int.Parse(addString) - int.Parse(index) + 1;
- firstInput = firstInput.Remove(int.Parse(index), removeCount);
- Console.WriteLine(firstInput);
- }
- else if (command == "Switch" && firstInput.Contains(index))
- {
- firstInput= firstInput.Replace(index, addString);
- Console.WriteLine(firstInput);
- }
- }
- else
- {
- break;
- }
- }
- Console.WriteLine($"Ready for world tour! Planned stops: {firstInput}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement