Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace Arriving_In_Kathmandu
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = "";
- string patern = @"^(?<nameofpeak>[A-Za-z0-9!@#$?]+)=(?<length>\d+)<<(?<code>(.*?)+)$";
- // ne e moi patern ^(?<nameofpeak>[A-Za-z0-9!@#$?]+)=(?<length>\d+)<<(?<code>(.*?)+)$
- // Dictionary<string, string> mountsInfo = new Dictionary<string, string>(); rechnika nqma da mi trqbva zashtto shte pechatam vutre v chikala tei kato iskat postoqno da se otpechatva suobshtenie
- while ((input = Console.ReadLine()) != "Last note")
- {
- var match = Regex.Match(input, patern);
- if (match.Success)
- {
- string onlyPeakName = "";
- string namePeak = match.Groups["nameofpeak"].Value;
- int lenght = int.Parse(match.Groups["length"].Value);
- string cordinate = match.Groups["code"].Value;
- if (cordinate.Length != lenght)
- {
- Console.WriteLine("Nothing found!");
- continue;
- }
- else
- {
- for (int i = 0; i < namePeak.Length; i++)
- {
- char simbol = namePeak[i];
- if (char.IsLetter(simbol))
- {
- onlyPeakName += simbol;
- }
- }
- Console.WriteLine($"Coordinates found! {onlyPeakName} -> {cordinate}");
- }
- //foreach (var item in namePeak)
- //{
- // char simbol = item;
- // if (char.IsLetter(simbol))
- // {
- // onlyPeakName += simbol;
- // }
- // else if (char.IsDigit(simbol))
- // {
- // onlyPeakName += (char)(simbol); // izlishno e da go castvam znam :D
- // }
- //}
- //if (onlyPeakName.Length == lenght || namePeak.Length == lenght || onlyPeakName.Length - 1 == lenght)
- //{
- // Console.WriteLine($"Coordinates found! {onlyPeakName} -> {cordinate}");
- //}
- //else
- //{
- // Console.WriteLine("Nothing found!");
- //}
- }
- else
- {
- Console.WriteLine("Nothing found!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment