Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dict = new Dictionary<string, Dictionary<string, List<int>>>();
- while (true)
- {
- Console.WriteLine("name/subject/grade or exit\n");
- var input = Console.ReadLine();
- var arguments = input.Split();
- if (input == "exit")
- {
- break;
- }
- if (!dict.ContainsKey(arguments[0]))
- {
- dict.Add(arguments[0], new Dictionary<string, List<int>>());
- dict[arguments[0]].Add(arguments[1], new List<int>());
- dict[arguments[0]][arguments[1]].Add(int.Parse(arguments[2]));
- }
- else
- {
- if(!dict[arguments[0]].ContainsKey(arguments[1]))
- {
- dict[arguments[0]].Add(arguments[1],new List<int>());
- dict[arguments[0]][arguments[1]].Add(int.Parse(arguments[2]));
- }
- else
- {
- dict[arguments[0]][arguments[1]].Add(int.Parse(arguments[2]));
- }
- }
- }
- foreach (var item in dict)
- {
- Console.WriteLine(item.Key);
- foreach (var item2 in dict[item.Key])
- {
- Console.WriteLine("Subject - " + item2.Key + " | Grade - " + String.Join(',',item2.Value));
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement