Advertisement
alidzhikov

NightLife

May 8th, 2015
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class NightLife
  4. {
  5.     static void Main()
  6.     {
  7.         Dictionary<string, SortedDictionary<string, SortedSet<string>>> nightLifeDictionary =
  8.                             new Dictionary<string, SortedDictionary<string, SortedSet<string>>>();
  9.  
  10.         string[] eventTokens;
  11.         string city = String.Empty;
  12.         string venue = String.Empty;
  13.         string performer = String.Empty;
  14.         string eventInformation = Console.ReadLine();
  15.  
  16.         while (eventInformation != "END")
  17.         {
  18.             eventTokens = eventInformation.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries);
  19.  
  20.             city = eventTokens[0];
  21.             venue = eventTokens[1];
  22.             performer = eventTokens[2];
  23.  
  24.             if (!nightLifeDictionary.ContainsKey(city))
  25.             {
  26.                 nightLifeDictionary[city] = new SortedDictionary<string, SortedSet<string>>();
  27.             }
  28.             if (!nightLifeDictionary[city].ContainsKey(venue))
  29.             {
  30.                 nightLifeDictionary[city][venue] = new SortedSet<string>();
  31.             }
  32.             nightLifeDictionary[city][venue].Add(performer);
  33.  
  34.             eventInformation = Console.ReadLine();
  35.         }
  36.  
  37.         foreach (var cityPair in nightLifeDictionary)
  38.         {
  39.             Console.WriteLine(cityPair.Key);
  40.             foreach (var venuePair in cityPair.Value)
  41.             {
  42.                 Console.WriteLine("->{0}: {1}", venuePair.Key, String.Join(", ", venuePair.Value));
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement