WindFell

Fixed

Jun 21st, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Numerics;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace ConsoleApp9
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.  
  16.             string input = Console.ReadLine();
  17.  
  18.         string pattern = @"^[a-zA-z]\w{2,24}$";
  19.         string[] usernames = input
  20.             .Split(" /\\()".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
  21.             .ToArray();
  22.         List<string> users = new List<string>();
  23.  
  24.         foreach (string user in usernames)
  25.         {
  26.             if (Regex.IsMatch(user, pattern))
  27.             {
  28.                 users.Add(user);
  29.             }
  30.         }
  31.  
  32.             int maxCount = 0;
  33.             string temp1 = string.Empty;
  34.             string temp2 = string.Empty;
  35.  
  36.             for (int i = 0; i < users.Count - 1; i++)
  37.             {
  38.                 if (users[i].Length + users[i + 1].Length > maxCount)
  39.                 {
  40.                     maxCount = users[i].Length + users[i + 1].Length;
  41.                     temp1 = users[i];
  42.                     temp2 = users[i + 1];
  43.                 }
  44.             }
  45.  
  46.             Console.WriteLine($"{temp1}\n{temp2}");
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment