Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Linq;
- using System.Collections.Generic;
- namespace _04.Regeh
- {
- class Regeh
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine();
- var pattern = @"\[[A-Z&a-z]+<([0-9]+)REGEH([0-9]+)>[A-Z&a-z]+\]";
- var regex = Regex.Matches(input, pattern);
- var num = new List<int>();
- string result = string.Empty;
- if (regex.Count==0) //това е добавката
- {
- return;
- }
- foreach (Match match in regex)
- {
- num.Add(int.Parse(match.Groups[1].Value));
- num.Add(int.Parse(match.Groups[2].Value));
- }
- int numLenght = num.Count;
- result += input[num[0]];
- int numSum = num[0];
- var inputLen = input.Length;
- for (int i = 1; i < numLenght; i++)
- {
- numSum += num[i];
- if (numSum >= input.Length)
- {
- result += input[(numSum % input.Length) + 1];
- }
- else
- {
- result += input[numSum % input.Length];
- }
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement