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.RegularExpressions;
- namespace RetakeFinalExamP01
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, double> mapPrice =
- new Dictionary<string, double>();
- Dictionary<string, string> mapDlc =
- new Dictionary<string, string>();
- string input = Console.ReadLine();
- string[] splitted = input.Split(", ");
- for (int i = 0; i < splitted.Length; i++)
- {
- string tokens = splitted[i];
- if (tokens.Contains("-"))
- {
- string[] gamesPrices = tokens.Split("-");
- string game = gamesPrices[0];
- double price = double.Parse(gamesPrices[1]);
- if (mapPrice.ContainsKey(game)==false)
- {
- mapPrice.Add(game, price);
- }
- }
- else
- {
- string[] gamesPrices = tokens.Split(":");
- string game = gamesPrices[0];
- string dlc = gamesPrices[1];
- if (mapPrice.Keys.Any(d => d.Contains(game)))
- {
- mapDlc.Add(game, dlc);
- }
- if (mapDlc.ContainsKey(game))
- {
- mapPrice[game] += 0.20 * mapPrice[game];
- }
- }
- }
- foreach (var game in mapPrice
- .OrderBy(x=>x.Value))
- {
- double price = 0.0;
- double loweredPrice = 0.0;
- if (mapDlc.ContainsKey(game.Key) == false)
- {
- price = game.Value;
- loweredPrice = price - 0.20 * price;
- }
- else
- {
- price = game.Value;
- loweredPrice = price - 0.50 * price;
- }
- foreach (var dlc in mapDlc)
- {
- if (game.Key == dlc.Key)
- {
- Console.WriteLine($"{dlc.Key} - {dlc.Value} - {loweredPrice:f2}");
- }
- }
- }
- foreach (var game in mapPrice.OrderByDescending(x=>x.Value))
- {
- double price = 0.0;
- double loweredPrice = 0.0;
- if (mapDlc.ContainsKey(game.Key) == false)
- {
- price = game.Value;
- loweredPrice = price - 0.20 * price;
- }
- else
- {
- price = game.Value;
- loweredPrice = price - 0.50 * price;
- }
- if (mapDlc.ContainsKey(game.Key) == false)
- {
- Console.WriteLine($"{game.Key} - {loweredPrice:f2}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement