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.Globalization;
- namespace Last_Exe
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Dictionary<string, double> entities = new Dictionary<string, double>();
- List<Clients> final = new List<Clients>();
- for (int i = 0; i < n; i++)
- {
- string[] input = Console.ReadLine().Split('-').ToArray();
- if (entities.ContainsKey(input[0]) == false)
- {
- entities.Add(input[0], double.Parse(input[1]));
- }
- entities[input[0]] = double.Parse(input[1]);
- }
- string current = Console.ReadLine();
- while (current != "ent of clients")
- {
- Clients client = new Clients();
- string[] splited = current.Split(new[] { "-", "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- if (entities.ContainsKey(splited[1]))
- {
- client.Name = splited[0];
- if (client.Order.ContainsKey(splited[1]) == false)
- {
- client.Order.Add(splited[1], int.Parse(splited[2]));
- }
- client.Order[splited[1]] += int.Parse(splited[2]);
- final.Add(client);
- }
- current = Console.ReadLine();
- }
- foreach (var client in final)
- {
- Console.WriteLine(client.Name);
- Console.WriteLine($"-- {client.Order.Keys} - {client.Order.Values}");
- Console.WriteLine($"BILL: {client.Order.Values.Sum()}");
- }
- }
- class Clients
- {
- public string Name { get; set; }
- public Dictionary<string, int> Order { get; set; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement