Advertisement
v4m4v4

UserLogs

Jul 31st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class UserLogs
  6. {
  7. static void Main(string[] args)
  8. {
  9. Dictionary<string, int> usersParameters = new Dictionary<string, int>();
  10. List<string> inputArguments = Console.ReadLine()
  11. .Split(new char[] { ' ', '=' }
  12. , StringSplitOptions
  13. .RemoveEmptyEntries)
  14. .ToList();
  15.  
  16. int count = 0;
  17.  
  18. while (inputArguments[0].Equals("end") == false)
  19. {
  20. string ip = inputArguments[1];
  21. string user = inputArguments[5];
  22.  
  23. if (!usersParameters.ContainsKey(ip))
  24. {
  25. usersParameters.Add(ip, count);
  26. }
  27. else
  28. {
  29. count++;
  30. usersParameters[ip] += count;
  31. }
  32.  
  33. inputArguments = Console.ReadLine()
  34. .Split(new char[] { ' ', '=' }
  35. , StringSplitOptions
  36. .RemoveEmptyEntries)
  37. .ToList();
  38. }
  39.  
  40. //Console.WriteLine($"{inputArguments[5]}");
  41.  
  42. foreach (var user in usersParameters)
  43. {
  44. Console.WriteLine($"{user.Key} -> {user.Value}");
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement