Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Program
- {
- public static void Main()
- {
- var line = Console.ReadLine().Split(' ');
- var users = new SortedDictionary<string, Dictionary<string, int>>();
- while (line[0] != "end")
- {
- var user = line[2].Split('=');
- var ip = line[0].Split('=');
- var userName = user[1];
- var ipAdress = ip[1];
- line = Console.ReadLine().Split(' ');
- InsertName(users, userName);
- InsertIP(users, userName, ipAdress);
- }
- foreach (var user in users)
- {
- Console.WriteLine($"{user.Key}:");
- Console.WriteLine(string.Join(", ", user.Value.Select(value => value.Key + " => " + value.Value).ToArray()) + ".");
- }
- }
- private static void InsertName(SortedDictionary<string, Dictionary<string, int>> users, string username)
- {
- if (!users.ContainsKey(username))
- {
- users[username] = new Dictionary<string, int>();
- }
- }
- private static void InsertIP(SortedDictionary<string, Dictionary<string, int>> users, string username, string ipAdress)
- {
- if (!users[username].ContainsKey(ipAdress))
- {
- users[username][ipAdress] = 0;
- }
- users[username][ipAdress] += 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement