Advertisement
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 FriendsFromRainyUniverse
- {
- class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, Dictionary<string, int>> AllData = new SortedDictionary<string, Dictionary<string, int>>();
- string input = Console.ReadLine();
- while (input != "End")
- {
- string[] SplittedInput = input.Split(new string[] { " -> ", ": " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- string NewPersonName = SplittedInput[0];
- string LiquidNameForTheNewPerson = SplittedInput[1];
- int JarCountForNewPerson = int.Parse(SplittedInput[2]);
- if (!AllData.ContainsKey(NewPersonName))
- {
- AllData[NewPersonName] = new Dictionary<string, int>();
- AllData[NewPersonName][LiquidNameForTheNewPerson] = JarCountForNewPerson;
- }
- else if (AllData[NewPersonName].ContainsKey(LiquidNameForTheNewPerson))
- {
- int NewJar = AllData[NewPersonName][LiquidNameForTheNewPerson] + JarCountForNewPerson;
- AllData[NewPersonName][LiquidNameForTheNewPerson] = NewJar;
- }
- else
- {
- AllData[NewPersonName][LiquidNameForTheNewPerson] = JarCountForNewPerson;
- }
- input = Console.ReadLine();
- }
- foreach (var Person in AllData)
- {
- Console.WriteLine($"{Person.Key} Liquids:");
- foreach (var item in Person.Value.OrderBy(x => x.Value))
- {
- Console.WriteLine($"--- {item.Key}: {item.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement