Stan0033

Untitled

Aug 5th, 2021
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. namespace apps
  8. {
  9. class Program
  10. {
  11. static string Get() { return Console.ReadLine(); }
  12.  
  13.  
  14.  
  15.  
  16. static void Main()
  17. {
  18. // santa helper
  19. int key = int.Parse(Get());
  20. //---------------------------------------
  21. string pattern = @"\@(?<name>[a-zA-Z]+)[\d\D]*(?<behavior>\!G\!)";
  22. //---------------------------------------
  23. List<string> allMatches = new List<string>(); // list for each line
  24. while (true)
  25. {
  26. string command = Get(); if (command == "end") { break; }
  27. char[] message = command.ToCharArray();
  28. string newstring = string.Empty;
  29. for (int i = 0; i < message.Length; i++){ newstring += (char)((int)message[i] - key); ;}
  30. allMatches.Add(newstring); //add to list
  31. }
  32. for (int i = 0; i < allMatches.Count; i++)
  33. {
  34. Match m = Regex.Match(allMatches[i], pattern);
  35. if (m.Success)
  36. {
  37. string name = m.Groups["name"].Value;
  38. Console.WriteLine(name);
  39. }
  40. }
  41.  
  42. }// END MAIN
  43.  
  44. }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment