Stan0033

Untitled

Aug 8th, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. using System.Text;
  6. namespace apps
  7. {
  8. class Program
  9. {
  10. static string Get() { return Console.ReadLine(); }
  11. static int GetInt() { return int.Parse(Console.ReadLine()); }
  12. static void Main()
  13. {
  14.  
  15. //pass reset
  16. string password = Get();
  17. char[] passwordAsChars = password.ToCharArray();
  18. string next = Get(); string end = "Done"; string arg1=string.Empty; string arg2=string.Empty;
  19. List<string> messages = new List<string>();
  20. while (next!= end)
  21. {
  22. string[] data = next.Split(" ").ToArray();
  23. string command = data[0];
  24. try
  25. {
  26. arg1 = data[1];
  27. arg2 = data[2];
  28. }
  29. catch { }
  30. switch(command)
  31. { ///--------------------------------------------------------------------------------
  32. ///--------------------------------------------------------------------------------
  33. case "TakeOdd":
  34. password = string.Empty;
  35. for (int i = 0; i < passwordAsChars.Length; i++)
  36. {
  37. if (i % 2 != 0)
  38. {
  39.  
  40. password += passwordAsChars[i];
  41. }
  42. }
  43. passwordAsChars = password.ToCharArray(); messages.Add(password) ; break;
  44. ///--------------------------------------------------------------------------------
  45. ///--------------------------------------------------------------------------------
  46. case "Cut": int index = int.Parse(arg1); int len = int.Parse(arg2); password = password.Remove(index, len); messages.Add(password); break;
  47. ///--------------------------------------------------------------------------------
  48. ///--------------------------------------------------------------------------------
  49. case "Substitute":
  50. if (password.Contains(arg1))
  51. {
  52. password = password.Replace(arg1, arg2);
  53. messages.Add(password);
  54. }
  55. else { messages.Add("Nothing to Replace!"); }
  56. break;
  57. }
  58. next = Get();
  59. }
  60. for (int i =0; i< messages.Count; i++) { if (i == messages.Count - 1) { Console.WriteLine($"Your password is: { password}"); } else { Console.WriteLine(messages[i]); } }
  61.  
  62. }
  63. }// END MAIN
  64.  
  65.  
  66. }
  67.  
  68.  
Advertisement
Add Comment
Please, Sign In to add comment