Guest User

Untitled

a guest
Aug 9th, 2020
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _01._World_Tour
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string firstInput = Console.ReadLine();
  12.  
  13.  
  14. while (true)
  15. {
  16. string input = Console.ReadLine();
  17. if (input != "Travel")
  18. {
  19. List<string> listInput = input.Split(':').ToList();
  20. string command = listInput[0];
  21. string index = listInput[1];
  22. string addString = listInput[2];
  23.  
  24. if (command == "Add Stop" && int.Parse(index) >=0 && int.Parse(index) < firstInput.Length)
  25. {
  26. firstInput = firstInput.Insert(int.Parse(index), addString);
  27. Console.WriteLine(firstInput);
  28. }
  29. else if (command == "Remove Stop" && int.Parse(index) >= 0 && int.Parse(index) < firstInput.Length
  30. && int.Parse(addString) >= 0 && int.Parse(addString) < firstInput.Length)
  31. {
  32. int removeCount = int.Parse(addString) - int.Parse(index) + 1;
  33. firstInput = firstInput.Remove(int.Parse(index), removeCount);
  34. Console.WriteLine(firstInput);
  35. }
  36. else if (command == "Switch" && firstInput.Contains(index))
  37. {
  38. firstInput= firstInput.Replace(index, addString);
  39. Console.WriteLine(firstInput);
  40. }
  41.  
  42. }
  43. else
  44. {
  45. break;
  46. }
  47. }
  48. Console.WriteLine($"Ready for world tour! Planned stops: {firstInput}");
  49. }
  50. }
  51. }
  52.  
RAW Paste Data