Advertisement
filipovv

userLogs

Jun 19th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace userLogs
  6. {
  7.     class MainClass
  8.     {
  9.         public static void Main(string[] args)
  10.         {
  11.             List<string> list = new List<string>(Console.ReadLine().Split(new[] { '=', ' ' }, StringSplitOptions.RemoveEmptyEntries));
  12.             SortedDictionary<string, Dictionary<string, int>> dict = new SortedDictionary<string, Dictionary<string, int>>();
  13.             while (list[0] != "end")
  14.             {
  15.                 for (int i = 0; i < list.Count; i += 6)
  16.                 {
  17.                     if (!dict.ContainsKey(list[i + 5]))
  18.                     {
  19.                         dict[list[i + 5]] = new Dictionary<string, int>();
  20.                     }
  21.  
  22.                     if (!dict[list[i + 5]].ContainsKey(list[i + 1]))
  23.                     {
  24.                         dict[list[i + 5]][list[i + 1]] = 1;
  25.                     }
  26.                     else
  27.                     {
  28.                         dict[list[i + 5]][list[i + 1]] += 1;
  29.                     }
  30.                 }
  31.                 list = new List<string>(Console.ReadLine().Split(new[] { '=', ' ' }, StringSplitOptions.RemoveEmptyEntries));
  32.             }
  33.             foreach (var item in dict)
  34.             {
  35.                 Console.WriteLine($"{item.Key}:");
  36.                 foreach (var entry in item.Value)
  37.                 {
  38.                     Console.Write(string.Join(", ", $"{entry.Key} => {entry.Value}"));
  39.                 }
  40.                 Console.Write('.');
  41.                 Console.WriteLine();
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement