Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
96
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.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Collections.Generic;
  6. namespace TheIsleOfMan
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string pattern = @"([#$%*&])(?<name>[A-z]+)(\1)\=(?<count>\d+)\!!(?<code>.+)";
  13. Regex regex = new Regex(pattern);
  14. while (true)
  15. {
  16. string input = Console.ReadLine();
  17.  
  18. if (regex.IsMatch(input))
  19. {
  20. int len = int.Parse(regex.Match(input).Groups["count"].Value);
  21. string geoCode = regex.Match(input).Groups["code"].Value;
  22. string name = regex.Match(input).Groups["name"].Value;
  23. if(len==geoCode.Length)
  24. {
  25. StringBuilder sb = new StringBuilder();
  26. sb.Append(geoCode);
  27. for(int i=0;i<len;i++)
  28. {
  29. sb[i]+= (char)len;
  30. }
  31. Console.WriteLine($"Coordinates found! {name} -> {sb}");
  32. break;
  33. }
  34. Console.WriteLine("Nothing found!");
  35. }
  36. else Console.WriteLine("Nothing found!");
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement