Advertisement
Guest User

Boss Rush / Final Exam Retake - 13 December 2019

a guest
Apr 5th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _02._Boss_Rush
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int numOfLine = int.Parse(Console.ReadLine());
  11.             Regex regex = new Regex(@"^\|([A-Z]{4,})\|:#([A-Z]{1}[a-z]+\s[a-z]+)#$");
  12.            
  13.             for (int i = 0; i < numOfLine; i++)
  14.             {
  15.                 string input = Console.ReadLine();
  16.                 Match match = regex.Match(input);
  17.                 if (match.Success)
  18.                 {
  19.                     string bossName = match.Groups[1].Value;
  20.                     string title = match.Groups[2].Value;
  21.                     Console.WriteLine($"{bossName}, The {title}");
  22.                     Console.WriteLine($">> Strength: {match.Groups[1].Length}");
  23.                     Console.WriteLine($">> Armour: {match.Groups[2].Length}");
  24.                 }
  25.                 else
  26.                 {
  27.                     Console.WriteLine("Access denied!");
  28.                 }
  29.             }            
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement