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;
- using System.Numerics;
- namespace VII_03_Exam
- {
- class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, Dictionary<string, long>> Persons = new SortedDictionary<string, Dictionary<string, long>>();
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "End") break;
- var tmp = command.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);
- string name = tmp[0];
- tmp = tmp[1].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
- string liquidname = tmp[0];
- long jarcount = long.Parse(tmp[1]);
- if (!Persons.ContainsKey(name))
- {
- Persons.Add(name, new Dictionary<string, long>());
- }
- if (!Persons[name].ContainsKey(liquidname))
- {
- Persons[name].Add(liquidname, 0);
- }
- Persons[name][liquidname] += jarcount;
- }
- foreach (var Person in Persons)
- {
- Console.WriteLine($"{Person.Key}Liquids:");
- var sortedcount = from entry in Person.Value orderby entry.Value ascending select entry;
- foreach (var liquid in sortedcount)
- {
- Console.WriteLine($"---{liquid.Key}: {liquid.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement