Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Program
- {
- class Dictionari
- {
- SortedDictionary<string, SortedDictionary<string, int[]>> firstYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
- SortedDictionary<string, SortedDictionary<string, int[]>> secondYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
- SortedDictionary<string, SortedDictionary<string, int[]>> thirdYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
- SortedDictionary<string, SortedDictionary<string, int[]>> fourtYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
- SortedDictionary<string, SortedDictionary<string, int[]>> fiftYear = new SortedDictionary<string, SortedDictionary<string, int[]>>();
- public Dictionari()
- {
- }
- public void CollectData(int year, string name, SortedDictionary<string, int[]> n)
- {
- switch (year)
- {
- case 1:
- firstYear.Add(name, n);
- break;
- case 2:
- secondYear.Add(name, n);
- break;
- case 3:
- thirdYear.Add(name, n);
- break;
- case 4:
- fourtYear.Add(name, n);
- break;
- case 5:
- fiftYear.Add(name, n);
- break;
- }
- }
- public void PrintGrade(int years)
- {
- switch (years)
- {
- case 1:
- foreach (var item in firstYear)
- {
- Console.WriteLine($"{item.Key} " );
- }
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
- case 5:
- break;
- }
- }
- static void Main(string[] args)
- {
- int years = 0;
- while (true)
- {
- Console.Write("Enter years of study: ");
- years = int.Parse(Console.ReadLine());
- if (years > 5)
- {
- Console.Clear();
- Console.WriteLine("Max years are 5!");
- }
- else
- {
- break;
- }
- Console.WriteLine();
- }
- SortedDictionary<string, int[]> data = new SortedDictionary<string, int[]>();
- Dictionari Dnevnik = new Dictionari();
- List<string> names = new List<string>();
- Console.Write("Enter students count: ");
- int studentsCount = int.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.Write("Enter students subjects: ");
- string[] typeOfSubject = Console.ReadLine().Split(new char[] { ' ', ',', '-', '/' });
- Console.WriteLine();
- int subjectsCount = typeOfSubject.Length;
- Console.Clear();
- for (int year = 1; year < years; year++)
- {
- if (year == 1)
- {
- for (int student = 1; student <= studentsCount; student++)
- {
- Console.Write("Enter student name: ");
- string name = Console.ReadLine();
- names.Add(name);
- for (int subject = 0; subject < subjectsCount; subject++)
- {
- Console.WriteLine("Enter grades for " + typeOfSubject[subject]);
- int[] grades = Console.ReadLine().Split(new char[] { ' ', ',' }).Select(int.Parse).ToArray();
- data.Add(typeOfSubject[subject], grades);
- }
- Dnevnik.CollectData(year, name, data);
- data.Clear();
- }
- }
- else
- {
- for (int student = 1; student <= studentsCount; student++)
- {
- Console.WriteLine($"Enter datas for {names[student - 1]}");
- for (int subject = 0; subject < subjectsCount; subject++)
- {
- Console.WriteLine("Enter grades for " + typeOfSubject[subject]);
- int[] grades = Console.ReadLine().Split(new char[] { ' ', ',' }).Select(int.Parse).ToArray();
- data.Add(typeOfSubject[subject], grades);
- }
- Dnevnik.CollectData(year, names[student - 1], data);
- data.Clear();
- }
- }
- Console.Clear();
- }
- Console.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement