Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace AsyncronousProgramming
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = Console.ReadLine();
- var input = new Dictionary<string, Dictionary<string, int>>();
- while (command != "end")
- {
- var tokens = command
- .Split(new string[] { "IP=", " ", "user=" }, StringSplitOptions.RemoveEmptyEntries);
- var ip = tokens[0];
- var user = tokens[2];
- if (!input.ContainsKey(user))
- {
- input.Add(user, new Dictionary<string, int>());
- }
- if (!input[user].ContainsKey(ip))
- {
- input[user].Add(ip, 0);
- }
- input[user][ip]++;
- command = Console.ReadLine();
- }
- foreach (var item in input.OrderBy(x => x.Key))
- {
- Console.WriteLine($"{item.Key}: ");
- Console.WriteLine($"{string.Join(", ", item.Value.Select(x=> $"{x.Key} => {x.Value}"))}.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement