Advertisement
loter

Andrey and Billiard1

Jul 19th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Globalization;
  5.  
  6. namespace Last_Exe
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int n = int.Parse(Console.ReadLine());
  13. Dictionary<string, double> entities = new Dictionary<string, double>();
  14. List<Clients> final = new List<Clients>();
  15.  
  16. for (int i = 0; i < n; i++)
  17. {
  18. string[] input = Console.ReadLine().Split('-').ToArray();
  19. if (entities.ContainsKey(input[0]) == false)
  20. {
  21. entities.Add(input[0], double.Parse(input[1]));
  22. }
  23.  
  24. entities[input[0]] = double.Parse(input[1]);
  25. }
  26.  
  27. string current = Console.ReadLine();
  28. while (current != "ent of clients")
  29. {
  30. Clients client = new Clients();
  31. string[] splited = current.Split(new[] { "-", "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  32. if (entities.ContainsKey(splited[1]))
  33. {
  34. client.Name = splited[0];
  35.  
  36. if (client.Order.ContainsKey(splited[1]) == false)
  37. {
  38. client.Order.Add(splited[1], int.Parse(splited[2]));
  39. }
  40.  
  41. client.Order[splited[1]] += int.Parse(splited[2]);
  42. final.Add(client);
  43.  
  44. }
  45. current = Console.ReadLine();
  46.  
  47. }
  48.  
  49. foreach (var client in final)
  50. {
  51. Console.WriteLine(client.Name);
  52. Console.WriteLine($"-- {client.Order.Keys} - {client.Order.Values}");
  53. Console.WriteLine($"BILL: {client.Order.Values.Sum()}");
  54.  
  55. }
  56. }
  57.  
  58. class Clients
  59. {
  60. public string Name { get; set; }
  61. public Dictionary<string, int> Order { get; set; }
  62.  
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement