Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication28
- {
- class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, SortedDictionary<string, double>> dataDictionary =
- new SortedDictionary<string, SortedDictionary<string, double>>();
- SortedDictionary<string, SortedDictionary<string, double>> dataO =
- new SortedDictionary<string, SortedDictionary<string, double>>();
- int dataLinesNumber = int.Parse(Console.ReadLine());
- string lineContents = String.Empty;
- string[] lineTokens;
- string student = "";
- string predmet = String.Empty;
- int ocenka = 0;
- int count = 2;
- for (int i = 0; i < dataLinesNumber; i++)
- {
- lineContents = Console.ReadLine();
- lineTokens = lineContents.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- student = (lineTokens[0]) + " " +(lineTokens[1]);
- predmet = lineTokens[2];
- ocenka = int.Parse(lineTokens[3]);
- if (!dataDictionary.ContainsKey(student))
- {
- dataDictionary[student] = new SortedDictionary<string, double>();
- }
- if (!dataDictionary[student].ContainsKey(predmet))
- {
- count = 1;
- dataDictionary[student][predmet] = count;
- }
- else
- {
- dataDictionary[student][predmet] = ++count;
- }
- /////////////////// 2 dictionary
- if (!dataO.ContainsKey(student))
- {
- dataO[student] = new SortedDictionary<string, double>();
- }
- if (!dataO[student].ContainsKey(predmet))
- {
- dataO[student][predmet] = ocenka;
- }
- else
- {
- dataO[student][predmet] += ocenka;
- }
- }
- ////////////////////////////////////////
- int kondio = 0;
- bool kur = true;
- int avg = 0;
- double sum = 0;
- bool isFirstPair = true;
- foreach (var cityPair in dataDictionary)
- {
- Console.Write(cityPair.Key + ": ");
- foreach (var venuePair in cityPair.Value)
- {
- kondio++;
- avg += 2;
- // if (kondio == 1 || kondio == 4)
- // {
- if (kondio % 2 != 0)
- {
- Console.Write("->{0}:", venuePair.Key); // , String.Join(", ", venuePair.Value)
- foreach (var item in dataO)
- {
- foreach (var em in item.Value)
- {
- if (kondio % 2 != 0)
- {
- // if (avg == 1 || avg == 8)
- // {
- sum = em.Value / venuePair.Value;
- Console.Write(" -- > {0:0.00}, ", sum);
- // }
- }
- }
- }
- // }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement