Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04._Orders
- {
- class Program
- {
- static void Main(string[] args)
- {
- var check = new Dictionary<string, List<string>>();
- while (true)
- {
- string[] input = Console.ReadLine().Split(' ').ToArray();
- string key = input[0];
- if (key=="buy")
- {
- foreach (var product in check)
- {
- double money = double.Parse(product.Value[0]) * double.Parse(product.Value[1]);
- product.Value[0] = $"{money:f2}";
- product.Value.RemoveAt(1);
- }
- break;
- }
- string price = input[1];
- string count = input[2];
- if (!check.ContainsKey(input[0]))
- {
- check.Add(key,new List<string> { price,count} );
- }
- else
- {
- check[key][0] = price;
- check[key][1] += count;
- }
- }
- foreach (var product in check)
- {
- Console.WriteLine($"{product.Key} -> {product.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement