Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] userNames = Console.ReadLine().Split(", ");
- List<string> validUserNames = new List<string>();
- for (int i = 0; i < userNames.Length; i++)
- {
- string user = userNames[i];
- int count = 0;
- if (user.Length >= 3 && user.Length <= 16)
- {
- foreach (var symbol in user)
- {
- if (char.IsLetterOrDigit(symbol) || symbol == '-' || symbol == '_')
- {
- count++;
- }
- }
- if (count == user.Length)
- {
- validUserNames.Add(user);
- }
- }
- }
- Console.WriteLine(string.Join(Environment.NewLine, validUserNames));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement