Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Numerics;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace ConsoleApp9
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string pattern = @"^[a-zA-z]\w{2,24}$";
- string[] usernames = input
- .Split(" /\\()".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
- .ToArray();
- List<string> users = new List<string>();
- foreach (string user in usernames)
- {
- if (Regex.IsMatch(user, pattern))
- {
- users.Add(user);
- }
- }
- int maxCount = 0;
- string temp1 = string.Empty;
- string temp2 = string.Empty;
- for (int i = 0; i < users.Count - 1; i++)
- {
- if (users[i].Length + users[i + 1].Length > maxCount)
- {
- maxCount = users[i].Length + users[i + 1].Length;
- temp1 = users[i];
- temp2 = users[i + 1];
- }
- }
- Console.WriteLine($"{temp1}\n{temp2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment