Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace softUniExamResults
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Students> examInformation = new Dictionary<string, Students>();
- Dictionary<string, int> languages = new Dictionary<string, int>();
- string command = Console.ReadLine();
- while (command != "exam finished")
- {
- string[] input = command.Split("-");
- string name = input[0];
- if (!command.Contains("banned"))
- {
- string language = input[1];
- int points = int.Parse(input[2]);
- if (!examInformation.ContainsKey(name))
- {
- examInformation.Add(name, new Students());
- }
- if (!languages.ContainsKey(language))
- {
- languages.Add(language, 0);
- }
- languages[language]++;
- if (!examInformation[name].Language.Contains(language))
- {
- examInformation[name].Language.Add(language);
- examInformation[name].Points.Add(points);
- }
- else
- {
- int index = examInformation[name].Language.FindIndex(x => x.Contains(language));
- if (examInformation[name].Language[index] == language && examInformation[name].Points[index] < points)
- {
- examInformation[name].Points[index] = points;
- }
- }
- }
- else
- {
- examInformation.Remove(name);
- }
- command = Console.ReadLine();
- }
- //examInformation = examInformation.OrderByDescending(x => x.Value.Points.Any()).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); ;
- Console.WriteLine("Results:");
- foreach (var kvp in examInformation)
- {
- Console.WriteLine($"{kvp.Key} | {string.Join($"\n{kvp.Key} | ", kvp.Value.Points)}");
- }
- languages = languages.OrderByDescending(x => x.Value).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
- Console.WriteLine("Submissions:");
- foreach (var kvp in languages)
- {
- Console.WriteLine($"{kvp.Key} - {kvp.Value}");
- }
- }
- }
- class Students
- {
- //public Dictionary<List<string>, List<int>> LanguageAndPoints { get; set; }
- public List<string> Language { get; set; } = new List<string>();
- public List<int> Points { get; set; } = new List<int>();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement