Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Text;
- using System.Linq;
- public class Program
- {
- public static void Main()
- {
- var logins = new Dictionary<string, string>();
- while (true)
- {
- var command = Console.ReadLine();
- if (command == "login")
- {
- break;
- }
- var userInfo = command.Split();
- var username = userInfo[0];
- var password = userInfo[2];
- logins[username] = password;
- }
- var count = 0;
- while (true)
- {
- var command = Console.ReadLine();
- if (command == "end")
- {
- break;
- }
- var loginInfo = command.Split();
- var username = loginInfo[0];
- var password = loginInfo[2];
- if (!logins.ContainsKey(username))
- {
- Console.WriteLine($"{username}: login failed");
- count++;
- }
- else if (logins.ContainsKey(username))
- {
- if (password == logins[username])
- {
- Console.WriteLine($"{username}: logged in successfully");
- }
- else
- {
- Console.WriteLine($"{username}: login failed");
- count++;
- }
- }
- }
- Console.WriteLine($"unsuccessful login attempts: {count}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement