Advertisement
vencinachev

School

Mar 16th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Program
  6. {
  7.     public static void Main()
  8.     {
  9.         Dictionary<String, List<String>> school = new Dictionary<String, List<String>>();
  10.        
  11.         while (true)
  12.         {
  13.             String[] command = Console.ReadLine().Split(' ');
  14.             if (command[0] == "End")
  15.             {
  16.                 break;
  17.             }
  18.             else if (command[0] == "Add")
  19.             {
  20.                 String student = command[1];
  21.                 String paralelka = command[2];
  22.                 if (school.ContainsKey(paralelka))
  23.                 {
  24.                     school[paralelka].Add(student);
  25.                 }
  26.                 else
  27.                 {
  28.                     /*List<String> newParalelka = new List<String>();
  29.                     newParalelka.Add(student);
  30.                     school[paralelka] = newParalelka;*/
  31.                     school[paralelka] = new List<String>();
  32.                     school[paralelka].Add(student);
  33.                 }
  34.             }
  35.         }
  36.        
  37.         foreach (String paralelka in school.Keys)
  38.         {
  39.             Console.WriteLine("Class name: " + paralelka);
  40.             foreach (String student in school[paralelka])
  41.             {
  42.                 Console.WriteLine("###" + student);
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement