Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace _02._Registration
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Regex regex = new Regex(@"^U\$([A-Z][a-z]{3,})U\$P@\$([a-z]{5,}[0-9]*)P@\$$");
- int count = 0;
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- Match match = regex.Match(input);
- if (match.Success)
- {
- count++;
- Console.WriteLine("Registration was successful");
- Console.WriteLine($"Username: {match.Groups[1].Value}, Password: {match.Groups[2].Value}");
- }
- else
- {
- Console.WriteLine("Invalid username or password");
- }
- }
- Console.WriteLine($"Successful registrations: {count}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement