Advertisement
Guest User

Untitled

a guest
Aug 8th, 2021
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System;
  2.  
  3. namespace WorldTour
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string text = Console.ReadLine();
  10.  
  11. string[] command = Console.ReadLine().Split(":");
  12.  
  13. while (command[0] != "Travel")
  14. {
  15. if (command[0] == "Add Stop")
  16. {
  17. if (int.Parse(command[1]) >= 0 && int.Parse(command[1]) <= text.Length - 1)
  18. {
  19. text = text.Insert(int.Parse(command[1]), command[2]);
  20. Console.WriteLine(text);
  21. }
  22. }
  23. else if (command[0] == "Remove Stop")
  24. {
  25. int startIndex = int.Parse(command[1]);
  26. int endIndex = int.Parse(command[2]);
  27.  
  28. if (startIndex >= 0 && endIndex >= 0 && startIndex <= text.Length - 1 && endIndex <= text.Length - 1 )
  29. {
  30. text = text.Remove(startIndex, endIndex + 1 - startIndex);
  31. Console.WriteLine(text);
  32. }
  33. }
  34. else if (command[0] == "Switch")
  35. {
  36. if (text.Contains(command[1]))
  37. {
  38. text = text.Replace(command[1], command[2]);
  39. Console.WriteLine(text);
  40. }
  41. }
  42.  
  43. command = Console.ReadLine().Split(":");
  44. }
  45.  
  46. Console.WriteLine($"Ready for world tour! Planned stops: {text}");
  47. }
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement