Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Text.RegularExpressions;
- namespace lab
- {
- public class lab
- {
- private static void Main()
- {
- var line = Console.ReadLine();
- while (line != "Over!")
- {
- var n = int.Parse(Console.ReadLine());
- var regex = new Regex("^(\\d+)([A-Za-z]{" + n + "})[^a-zA-Z]*?(\\d+)?$");
- var match = regex.Match(line);
- if (match.Success)
- {
- string text = match.Groups[2].ToString();
- var left = match.Groups[1].ToString().ToCharArray();
- var right = match.Groups[3].ToString().ToCharArray();
- Console.Write(match.Groups[2]);
- Console.Write(" == ");
- for (int i = 0; i < left.Length; i++)
- {
- if (int.Parse(left[i].ToString()) < text.Length)
- {
- Console.Write(text[int.Parse(left[i].ToString())]);
- }
- else
- {
- Console.Write(" ");
- }
- }
- if (right.Length > 0)
- {
- for (int i = 0; i < right.Length; i++)
- {
- if (char.IsDigit(right[i]))
- {
- if (int.Parse(right[i].ToString()) < text.Length)
- {
- Console.Write(text[int.Parse(right[i].ToString())]);
- }
- else
- {
- Console.Write(" ");
- }
- }
- }
- }
- Console.WriteLine();
- }
- line = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement