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.RegularExpressions;
- using System.Text;
- namespace Final_Exam
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string[] command = Console.ReadLine().Split(':');
- while (command[0] != "Travel")
- {
- if (command[0] == "Add Stop")
- {
- //• Add Stop:{index}:{string}
- int index = int.Parse(command[1]);
- if (index >= 0 && index < input.Length)
- {
- input = input.Insert(index, command[2]);
- //Console.WriteLine(input);
- }
- }
- if (command[0] == "Remove Stop")
- {
- //• Remove Stop:{start_index}:{end_index}
- int start = int.Parse(command[1]);
- int end = int.Parse(command[2]);
- if ((start >= 0 && start < input.Length) && end >= 0 && end < input.Length)
- {
- input = input.Remove(start, end - start + 1);
- //Console.WriteLine(input);
- }
- }
- if (command[0] == "Switch")
- {
- //• Switch:{old_string}:{new_string}
- if (input.Contains(command[1]))
- {
- input = input.Replace(command[1], command[2]);
- //Console.WriteLine(input);
- }
- }
- Console.WriteLine(input);
- command = Console.ReadLine().Split(':');
- }
- Console.WriteLine($"Ready for world tour! Planned stops: {input}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement