Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _06Problem_UserLog
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(new char[] { '=', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- var userLogs = new SortedDictionary<string, Dictionary<string, int>>();
- while (!input[0].Equals("end"))
- {
- string currentIpAddress = input[1];
- string currentUser = input[input.Length - 1];
- if (userLogs.ContainsKey(currentUser) == false)
- {
- userLogs.Add(currentUser, new Dictionary<string, int>());
- userLogs[currentUser].Add(currentIpAddress, 1);
- }
- else
- {
- if (userLogs[currentUser].ContainsKey(currentIpAddress) == false)
- {
- userLogs[currentUser].Add(currentIpAddress, 1);
- }
- else
- {
- userLogs[currentUser][currentIpAddress]++;
- }
- }
- input = Console.ReadLine().Split(new char[] { '=', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- }
- foreach (var kvp in userLogs)
- {
- Console.WriteLine($"{kvp.Key}: ");
- string[] result = kvp.Value.Select(x => $"{x.Key} => {x.Value}").ToArray();
- Console.WriteLine("{0}.", string.Join(", ", result));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement