Again_89

2ра задача

Apr 6th, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _02._Deciphering
  5. {
  6. class Program
  7. {
  8. static void Main()
  9. {
  10. var firstLine = Console.ReadLine();
  11. var secondLine = Console.ReadLine().Split();
  12.  
  13. var pattern = @"^[d-z{}|#]+$";
  14.  
  15. if (Regex.IsMatch(firstLine, pattern))
  16. {
  17. var word = Regex.Match(firstLine, pattern).ToString().ToCharArray();
  18. for (int i = 0; i < word.Length; i++)
  19. {
  20. var symbol = (char)(word[i] - 3);
  21. word[i] = symbol;
  22. }
  23. var finalWord = new string(word);
  24.  
  25. var result = finalWord.Replace(secondLine[0], secondLine[1]);
  26. Console.WriteLine(result);
  27. }
  28. else
  29. {
  30. Console.WriteLine("This is not the book you are looking for.");
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment