Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, string[]> games = new Dictionary<string, string[]>();
- string[] input = Console.ReadLine().Split(", ", StringSplitOptions.RemoveEmptyEntries);
- foreach (var item in input)
- {
- if (item.Contains("-"))
- {
- string[] tokens = item.Split('-');
- string game = tokens[0];
- string price = tokens[1];
- games[game] = new string[2];
- games[game][0] = price;
- }
- else if (item.Contains(":"))
- {
- string[] tokens = item.Split(':');
- string game = tokens[0];
- string dlc = tokens[1];
- if (games.ContainsKey(game))
- {
- games[game][1] = dlc;
- games[game][0] = (decimal.Parse(games[game][0]) * 1.2m).ToString();
- }
- }
- }
- foreach (var item in games.OrderBy(x => decimal.Parse(x.Value[0])))
- {
- if (item.Value[1] != null)
- {
- Console.WriteLine($"{item.Key} - {item.Value[1]} - {decimal.Parse(item.Value[0]) * 0.5m:F2}");
- }
- }
- foreach (var item in games.OrderByDescending(x => decimal.Parse(x.Value[0])))
- {
- if (item.Value[1] == null)
- {
- Console.WriteLine($"{item.Key} - {decimal.Parse(item.Value[0]) * 0.8m:F2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement