Advertisement
Guest User

Untitled

a guest
Oct 7th, 2016
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 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 _06.UserLogs
  8. {
  9. class Program
  10. {
  11. static void Main()
  12. {
  13. var dict = new SortedDictionary<string, int>();
  14.  
  15. while (true)
  16. {
  17. int counter = 1;
  18. var inPut = Console.ReadLine().Split(' ').ToList();
  19. if (inPut[0] == "end")
  20. {
  21. break;
  22. }
  23. var ArrayIP = inPut[0].Split('='); // splitvam po '=' za da vzema IP adresa
  24. string ip = ArrayIP[1];
  25. var ArrayName = inPut[2].Split('='); // splitvam po '=' za da vzema name-a
  26. string name = ArrayName[1];
  27. if (dict.ContainsKey(ip))
  28. {
  29. dict[ip]++;
  30.  
  31. }
  32. else
  33. {
  34. dict.Add(ip, counter);
  35. }
  36.  
  37.  
  38.  
  39. }
  40.  
  41. PrintDict(dict);
  42.  
  43. }
  44.  
  45. private static void PrintDict(SortedDictionary<string, int> dict)
  46. {
  47. foreach (var pair in dict)
  48. {
  49.  
  50. Console.WriteLine("{0} -> {1}",pair.Key,pair.Value);
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement