Advertisement
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 _06.UserLogs
- {
- class Program
- {
- static void Main()
- {
- var dict = new SortedDictionary<string, int>();
- while (true)
- {
- int counter = 1;
- var inPut = Console.ReadLine().Split(' ').ToList();
- if (inPut[0] == "end")
- {
- break;
- }
- var ArrayIP = inPut[0].Split('='); // splitvam po '=' za da vzema IP adresa
- string ip = ArrayIP[1];
- var ArrayName = inPut[2].Split('='); // splitvam po '=' za da vzema name-a
- string name = ArrayName[1];
- if (dict.ContainsKey(ip))
- {
- dict[ip]++;
- }
- else
- {
- dict.Add(ip, counter);
- }
- }
- PrintDict(dict);
- }
- private static void PrintDict(SortedDictionary<string, int> dict)
- {
- foreach (var pair in dict)
- {
- Console.WriteLine("{0} -> {1}",pair.Key,pair.Value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement