Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Plant_Discovery
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberOfPlants = int.Parse(Console.ReadLine());
- Dictionary<string, int> rarities = new Dictionary<string, int>();
- Dictionary<string, List<double>> ratings = new Dictionary<string, List<double>>();
- for (int i = 0; i < numberOfPlants; i++)
- {
- string[] informtionForPlants = Console.ReadLine().Split("<->");
- string plant = informtionForPlants[0];
- int rarity = int.Parse(informtionForPlants[1]);
- rarities.Add(plant, rarity);
- ratings.Add(plant, new List<double>());
- }
- string command;
- while ((command = Console.ReadLine()) != "Exhibition")
- {
- string[] receivedCommand = command.Split(": ");
- string firstPartOfCommand = receivedCommand[0];
- string[] secondPartOfCommand = receivedCommand[1].Split(" - ");
- string plant = secondPartOfCommand[0];
- if (firstPartOfCommand == "Rate")
- {
- int rating = int.Parse(secondPartOfCommand[1]);
- ratings[plant].Add(rating);
- }
- else if (firstPartOfCommand == "Update")
- {
- int rarity = int.Parse(secondPartOfCommand[1]);
- rarities[plant] = rarity;
- }
- else if (firstPartOfCommand == "Reset")
- {
- ratings[plant].RemoveAll(x => x > 0);
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- Console.WriteLine("Plants for the exhibition:");
- foreach (var kvp in rarities.OrderByDescending(x => x.Value).ThenByDescending(x => x.Key))
- {
- Console.Write($"- {kvp.Key}; Rarity: {kvp.Value}; ");
- /*foreach (var item in ratings.OrderByDescending(x => x.Value.Sum() / x.Value.Count))
- {
- }*/
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement