Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace User_Logs
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Dictionary<string, Dictionary<string, int>> usersInfo = new Dictionary<string, Dictionary<string, int>>();
- while (input !="end")
- {
- var ip = input.Split(new char[] {' ','='}, StringSplitOptions.RemoveEmptyEntries).Skip(1).Take(1).ToList();
- var userName = input.Split(new char[] { ' ', '=' }, StringSplitOptions.RemoveEmptyEntries).TakeLast(1).ToList();
- //
- if (!usersInfo.ContainsKey(userName[0]))
- {
- Dictionary<string, int> current = new Dictionary<string, int>();
- current.Add(ip[0], 0);
- usersInfo.Add(userName[0], current );
- }
- if (!usersInfo[userName[0]].ContainsKey(ip[0]))
- {
- usersInfo[userName[0]].Add(ip[0], 0);
- }
- usersInfo[userName[0]][ip[0]]++;
- input = Console.ReadLine();
- }
- foreach (var item in usersInfo.OrderBy(x => x.Key))
- {
- Console.WriteLine(item.Key+":");
- var count = item.Value.Count;
- foreach (var personalData in item.Value)
- {
- count--;
- if (count>0)
- {
- Console.Write(personalData.Key + " => " + personalData.Value + ", ");
- }
- else
- {
- Console.Write(personalData.Key + " => " + personalData.Value + ".");
- }
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement