Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp1
  6. {
  7.     class Program
  8.     {
  9.         class Dictionari
  10.         {
  11.             SortedDictionary<string, SortedDictionary<string, int[]>> firstYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
  12.             SortedDictionary<string, SortedDictionary<string, int[]>> secondYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
  13.             SortedDictionary<string, SortedDictionary<string, int[]>> thirdYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
  14.             SortedDictionary<string, SortedDictionary<string, int[]>> fourtYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
  15.             SortedDictionary<string, SortedDictionary<string, int[]>> fiftYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
  16.  
  17.             public Dictionari()
  18.             {
  19.  
  20.             }
  21.             public void CollectData(int year, string name, SortedDictionary<string, int[]> n)
  22.             {
  23.  
  24.  
  25.                 switch (year)
  26.                 {
  27.                     case 1:
  28.                         firstYear.Add(name, n);
  29.                         break;
  30.                     case 2:
  31.                         secondYear.Add(name, n);
  32.                         break;
  33.                     case 3:
  34.                         thirdYear.Add(name, n);
  35.                         break;
  36.                     case 4:
  37.                         fourtYear.Add(name, n);
  38.                         break;
  39.                     case 5:
  40.                         fiftYear.Add(name, n);
  41.                         break;
  42.                 }
  43.             }
  44.             public void PrintGrade(int years)
  45.             {
  46.                 switch (years)
  47.                 {
  48.                     case 1:
  49.                         foreach (var item in firstYear)
  50.                         {
  51.                             Console.WriteLine($"{item.Key}  " );
  52.                            
  53.                         }
  54.                         break;
  55.                     case 2:
  56.                         break;
  57.                     case 3:
  58.                         break;
  59.                     case 4:
  60.                         break;
  61.                     case 5:
  62.                         break;
  63.                 }
  64.             }
  65.             static void Main(string[] args)
  66.             {
  67.                 int years = 0;
  68.  
  69.                 while (true)
  70.                 {
  71.                     Console.Write("Enter years of study: ");
  72.                     years = int.Parse(Console.ReadLine());
  73.                     if (years > 5)
  74.                     {
  75.                         Console.Clear();
  76.                         Console.WriteLine("Max years are 5!");
  77.                     }
  78.                     else
  79.                     {
  80.                         break;
  81.                     }
  82.                     Console.WriteLine();
  83.                 }
  84.  
  85.  
  86.                 SortedDictionary<string, int[]> data = new SortedDictionary<string, int[]>();
  87.                 Dictionari Dnevnik = new Dictionari();
  88.                 List<string> names = new List<string>();
  89.  
  90.                 Console.Write("Enter students count: ");
  91.                 int studentsCount = int.Parse(Console.ReadLine());
  92.                 Console.WriteLine();
  93.                 Console.Write("Enter students subjects: ");
  94.                 string[] typeOfSubject = Console.ReadLine().Split(new char[] { ' ', ',', '-', '/' });
  95.                 Console.WriteLine();
  96.                 int subjectsCount = typeOfSubject.Length;
  97.                 Console.Clear();
  98.                 for (int year = 1; year < years; year++)
  99.                 {
  100.                     if (year == 1)
  101.                     {
  102.                         for (int student = 1; student <= studentsCount; student++)
  103.                         {
  104.                             Console.Write("Enter student name: ");
  105.                             string name = Console.ReadLine();
  106.                             names.Add(name);
  107.                             for (int subject = 0; subject < subjectsCount; subject++)
  108.                             {
  109.                                 Console.WriteLine("Enter grades for " + typeOfSubject[subject]);
  110.                                 int[] grades = Console.ReadLine().Split(new char[] { ' ', ',' }).Select(int.Parse).ToArray();
  111.                                 data.Add(typeOfSubject[subject], grades);
  112.                             }
  113.                             Dnevnik.CollectData(year, name, data);
  114.                             data.Clear();
  115.                         }
  116.                     }
  117.                     else
  118.                     {
  119.                         for (int student = 1; student <= studentsCount; student++)
  120.                         {
  121.                             Console.WriteLine($"Enter datas for {names[student - 1]}");
  122.                             for (int subject = 0; subject < subjectsCount; subject++)
  123.                             {
  124.  
  125.                                 Console.WriteLine("Enter grades for " + typeOfSubject[subject]);
  126.                                 int[] grades = Console.ReadLine().Split(new char[] { ' ', ',' }).Select(int.Parse).ToArray();
  127.                                 data.Add(typeOfSubject[subject], grades);
  128.                             }
  129.                             Dnevnik.CollectData(year, names[student - 1], data);
  130.                             data.Clear();
  131.                         }
  132.                     }
  133.                     Console.Clear();
  134.                 }
  135.                 Console.Clear();
  136.             }
  137.  
  138.         }
  139.     }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement