Advertisement
Guest User

Untitled

a guest
Feb 6th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. namespace _04.Regeh
  6. {
  7. class Regeh
  8. {
  9. static void Main(string[] args)
  10. {
  11. var input = Console.ReadLine();
  12. var pattern = @"\[[A-Z&a-z]+<([0-9]+)REGEH([0-9]+)>[A-Z&a-z]+\]";
  13. var regex = Regex.Matches(input, pattern);
  14. var num = new List<int>();
  15. string result = string.Empty;
  16. if (regex.Count==0) //това е добавката
  17. {
  18. return;
  19. }
  20. foreach (Match match in regex)
  21. {
  22. num.Add(int.Parse(match.Groups[1].Value));
  23. num.Add(int.Parse(match.Groups[2].Value));
  24. }
  25. int numLenght = num.Count;
  26. result += input[num[0]];
  27. int numSum = num[0];
  28. var inputLen = input.Length;
  29. for (int i = 1; i < numLenght; i++)
  30. {
  31. numSum += num[i];
  32. if (numSum >= input.Length)
  33. {
  34.  
  35. result += input[(numSum % input.Length) + 1];
  36. }
  37. else
  38. {
  39.  
  40. result += input[numSum % input.Length];
  41. }
  42.  
  43.  
  44. }
  45.  
  46. Console.WriteLine(result);
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement