Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace WorldTour
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string command = Console.ReadLine();
- while (command != "Travel")
- {
- string[] cmd = command.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
- if (cmd[0] == "Add Stop")
- {
- if (int.Parse(cmd[1]) < input.Length)
- {
- int index = int.Parse(cmd[1]);
- string str = cmd[2];
- input = input.Insert(index, str);
- }
- Console.WriteLine(input);
- }
- else if (cmd[0] == "Remove Stop")
- {
- if (int.Parse(cmd[1]) < input.Length && int.Parse(cmd[2]) < input.Length)
- {
- input = input.Remove(int.Parse(cmd[1]), int.Parse(cmd[2]) - int.Parse(cmd[1]) + 1);
- }
- Console.WriteLine(input);
- }
- else if (cmd[0] == "Switch")
- {
- if (input.Contains(cmd[1]))
- {
- input = input.Replace(cmd[1], cmd[2]);
- }
- Console.WriteLine(input);
- }
- command = Console.ReadLine();
- }
- Console.WriteLine($"Ready for world tour! Planned stops: {input}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement