Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class Program
- {
- static void PrintTheNightBook(Dictionary<string, SortedDictionary<string, SortedSet<string>>> nightBook) // method to print the nightBook;
- {
- foreach (var town in nightBook)
- {
- Console.WriteLine(town.Key);
- foreach (var clubs in town.Value)
- {
- Console.Write(" --> {0}: {1}", clubs.Key, string.Join(", ", clubs.Value));
- Console.WriteLine();
- }
- }
- }
- static void Main()
- {
- Dictionary<string, SortedDictionary<string, SortedSet<string>>> nightBook = new Dictionary<string, SortedDictionary<string, SortedSet<string>>>();
- string input = Console.ReadLine();
- string city = string.Empty;
- string place = string.Empty;
- string performer = string.Empty;
- while (input != "END") //Fill out the NightBook;
- {
- var cityPlacePerformer = new List<string>(input.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList());
- city = cityPlacePerformer[0];
- place = cityPlacePerformer[1];
- performer = cityPlacePerformer[2];
- if (!nightBook.ContainsKey(city))
- {
- nightBook[city] = new SortedDictionary<string, SortedSet<string>>();
- }
- if (!nightBook[city].ContainsKey(place))
- {
- nightBook[city][place] = new SortedSet<string>();
- }
- nightBook[city][place].Add(performer);
- input = Console.ReadLine();
- }
- PrintTheNightBook(nightBook);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment