Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace test
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string pattern = @"([#$%*&])(?<name>[A-z]+)(\1)=(?<lenght>\d+)!!(?<code>.+)";
  15.             string input = Console.ReadLine();
  16.             while (true)
  17.             {
  18.                 Regex order = new Regex(pattern);
  19.                 if (order.IsMatch(input))
  20.                 {
  21.                     string name = order.Match(input).Groups["name"].Value;
  22.                     int lenght = int.Parse(order.Match(input).Groups["lenght"].Value);
  23.                     string code = order.Match(input).Groups["code"].Value;
  24.                     if (lenght == code.Length)
  25.                     {
  26.                         StringBuilder codee = new StringBuilder();
  27.                         for (int i = 0; i < code.Length; i++)
  28.                         {
  29.                             char symbol = (char)(code[i] + lenght);
  30.                             codee.Append(symbol);
  31.                         }
  32.                         Console.WriteLine($"Coordinates found! {name} -> {codee}");
  33.                         return;
  34.                     }
  35.                     else
  36.                     {
  37.                         Console.WriteLine("Nothing found!");
  38.                     }
  39.  
  40.  
  41.  
  42.                 }
  43.                 else
  44.                 {
  45.                     Console.WriteLine("Nothing found!");
  46.                 }
  47.  
  48.                 input = Console.ReadLine();
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement