Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace Arriving_in_Kathmandu
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string command = Console.ReadLine();
  12. string pattern = @"^(?<name>[A-Za-z0-9!@#$?]+)=(?<length>[\d]+)<<(?<code>.+)$";
  13. StringBuilder nameToPrint = new StringBuilder();
  14.  
  15. while (command!="Last note")
  16. {
  17. Match match = Regex.Match(command, pattern);
  18.  
  19. string name = match.Groups["name"].Value;
  20.  
  21. int length =0;
  22. string code = "";
  23. if (name.Length!=0)
  24. {
  25. length = int.Parse(match.Groups["length"].Value);
  26. code = match.Groups["code"].Value;
  27. if (length != code.Length)
  28. {
  29. Console.WriteLine("Nothing found!");
  30. }
  31. if (length == code.Length)
  32. {
  33. for (int i = 0; i < name.Length; i++)
  34. {
  35. int letter = name[i];
  36. if (letter!=33 && letter!=64 && letter!=35 && letter!= 36 && letter!=63)
  37. {
  38. nameToPrint.Append(name[i]);
  39. }
  40. }
  41. Console.WriteLine($"Coordinates found! {nameToPrint} -> {code}");
  42.  
  43. }
  44. }
  45. else
  46. {
  47. Console.WriteLine("Nothing found!");
  48. }
  49.  
  50. command = Console.ReadLine();
  51. }
  52.  
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement