Advertisement
osman1997

02. problem Final exam 13 dec 2020

Dec 13th, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6.  
  7. class Program
  8. {
  9.  
  10. static void Main()
  11. {
  12. int n = int.Parse(Console.ReadLine());
  13.  
  14.  
  15.  
  16. for (int i = 0; i < n; i++)
  17. {
  18. string input = Console.ReadLine();
  19.  
  20. Regex pattern = new Regex(@"!([A-Z][a-z]{3,})!:\[([A-Za-z]{8,})\]");
  21.  
  22. Match matches = pattern.Match(input);
  23.  
  24. if (matches.Success)
  25. {
  26. string command = matches.Groups[1].Value;
  27. string pass = matches.Groups[2].Value;
  28.  
  29. Console.Write($"{command}: ");
  30. for (int r = 0; r < pass.Length; r++)
  31. {
  32. int diff = (int)pass[r];
  33. Console.Write(diff + " ");
  34. }
  35. Console.WriteLine();
  36.  
  37. }
  38. else
  39. {
  40. Console.WriteLine("The message is invalid");
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement