Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Exam
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] input = Console.ReadLine().Split(new char[] { ' ','-','>'},StringSplitOptions.RemoveEmptyEntries);
  14. var result = new Dictionary<string, string>();
  15.  
  16.  
  17. int unsuccessful = 0;
  18. while (input[0]!="login")
  19. {
  20. string username = input[0];
  21. string password = input[1];
  22.  
  23. result[username] = password;
  24. input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
  25. }
  26.  
  27.  
  28.  
  29. input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
  30. while (input[0]!="end")
  31. {
  32. string username = input[0];
  33. string password = input[1];
  34.  
  35. if (result[username] == password)
  36. {
  37. Console.WriteLine($"{username}: logged in successfully");
  38.  
  39. }
  40. else
  41. {
  42. Console.WriteLine($"{username}: login failed");
  43. unsuccessful++;
  44. }
  45. input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);
  46. }
  47.  
  48. Console.WriteLine($"unsuccessful login attempts: {unsuccessful}");
  49.  
  50.  
  51.  
  52. }
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement