Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class NightLife
- {
- public static void Main()
- {
- var data =new Dictionary<string, SortedDictionary<string, SortedSet<string>>>();
- string line = Console.ReadLine();
- string[] input;
- string city = String.Empty;
- string venue = String.Empty;
- string performer = String.Empty;
- while (line != "END")
- {
- input = line.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
- city = input[0];
- venue = input[1];
- performer = input[2];
- if (!data.ContainsKey(city)) // проверяваш дали го има този град,ако го няма го добавяш
- {
- data[city] = new SortedDictionary<string, SortedSet<string>>();
- }
- if (!data[city].ContainsKey(venue)) // проверяваш дали градът съдържа авенюто, ако го няма го добавяш
- {
- data[city][venue] = new SortedSet<string>();
- }
- data[city][venue].Add(performer); //добавяш участника , понеже си със хаш сетове , те пазят само уникалните стойности
- line = Console.ReadLine();
- }
- foreach (var cityPair in data)
- {
- Console.WriteLine(cityPair.Key);
- foreach (var venuePair in cityPair.Value)
- {
- Console.WriteLine("->{0}: {1}", venuePair.Key, String.Join(", ", venuePair.Value));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment