Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Exam
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(new char[] { ' ','-','>'},StringSplitOptions.RemoveEmptyEntries);
- var result = new Dictionary<string, string>();
- int unsuccessful = 0;
- while (input[0]!="login")
- {
- string username = input[0];
- string password = input[1];
- result[username] = password;
- input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
- }
- input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
- while (input[0]!="end")
- {
- string username = input[0];
- string password = input[1];
- if (result[username] == password)
- {
- Console.WriteLine($"{username}: logged in successfully");
- }
- else
- {
- Console.WriteLine($"{username}: login failed");
- unsuccessful++;
- }
- input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
- }
- Console.WriteLine($"unsuccessful login attempts: {unsuccessful}");
- }
- }
- }
Add Comment
Please, Sign In to add comment