Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace DICT_LMBD_And_LINQ
- {
- class Program
- {
- static void Main()
- {
- Dictionary<string, int> students = new Dictionary<string, int>();
- Dictionary<string, int> languages = new Dictionary<string, int>();
- List<string> bannedDudes = new List<string>();
- while (true)
- {
- string[] tokens = Console.ReadLine().Split('-');
- if (tokens[0] == "exam finished")
- {
- break;
- }
- string name = tokens[0];
- string lan = tokens[1];
- if (tokens[1] == "banned")
- {
- bannedDudes.Add(name);
- continue;
- }
- int points = int.Parse(tokens[2]);
- if (students.ContainsKey(name) == false)
- {
- students.Add(name, 0);
- }
- students[name] = points;
- if (languages.ContainsKey(lan) == false)
- {
- languages.Add(lan, 0);
- }
- languages[lan] += 1;
- }
- var sorted = students.OrderByDescending(p => p.Value).ThenBy(p => p.Key);
- Console.WriteLine("Results:");
- foreach (var student in sorted)
- {
- if (bannedDudes.Contains(student.Key))
- {
- continue;
- }
- Console.WriteLine("{0} | {1}", student.Key, student.Value);
- }
- var sortedLan = languages.OrderByDescending(c => c.Value).ThenBy(l => l.Key);
- Console.WriteLine("Submissions:");
- foreach (var language in sortedLan)
- {
- Console.WriteLine("{0} - {1}", language.Key, language.Value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement