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;
- namespace ConsoleApplication7
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, SortedDictionary<string, List<string>>> cities = new Dictionary<string, SortedDictionary<string, List<string>>>();
- string input = Console.ReadLine();
- string[] inputData = input.Split(';');
- while (input != "END")
- {
- if (cities.ContainsKey(inputData[0]) == false)
- {
- cities.Add(inputData[0], new SortedDictionary<string, List<string>>());
- List<string> check = new List<string>();
- cities[inputData[0]].Add(inputData[1], new List<string>());
- cities[inputData[0]][inputData[1]].Add(inputData[2]);
- }
- else
- {
- if (cities[inputData[0]].ContainsKey(inputData[1]) == false)
- {
- cities[inputData[0]].Add(inputData[1], new List<string>());
- cities[inputData[0]][inputData[1]].Add(inputData[2]);
- }
- else
- {
- cities[inputData[0]][inputData[1]].Add(inputData[2]);
- }
- }
- input = Console.ReadLine();
- inputData = input.Split(';');
- }
- foreach (var town in cities.Keys)
- {
- Console.WriteLine(town);
- foreach (var item in cities[town].Keys)
- {
- Console.WriteLine("->{0}:{1}", item, string.Join(", ", string.Join(", ", cities[town][item])));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment