Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- namespace Mentor_Group
- {
- class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, List<DateTime>> DataDictionary = new SortedDictionary<string, List<DateTime>>();
- Dictionary<string, List<string>> ComentDictionary = new Dictionary<string, List<string>>();
- while (true)
- {
- string Input = Console.ReadLine();
- if (Input == "end of dates") break;
- string[] DataInput = Input.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- string Name = DataInput[0];
- if (!DataDictionary.ContainsKey(Name))
- {
- List<DateTime> Data = new List<DateTime>();
- for (int i = 1; i < DataInput.Length; i++)
- {
- DateTime CurrentData = DateTime.ParseExact(DataInput[i], "dd/MM/yyyy", CultureInfo.InvariantCulture);
- //if (!Data.Contains(CurrentData))
- //{
- Data.Add(CurrentData);
- //}
- }
- DataDictionary.Add(Name, Data);
- }
- else
- {
- List<DateTime> Data = DataDictionary[Name];
- for (int i = 1; i < DataInput.Length; i++)
- {
- DateTime CurrentData = DateTime.ParseExact(DataInput[i], "dd/MM/yyyy", CultureInfo.InvariantCulture);
- //if (!Data.Contains(CurrentData))
- //{
- Data.Add(CurrentData);
- //}
- }
- // DataDictionary.Add(Name, Data);
- DataDictionary[Name] = Data;
- }
- }
- while (true)
- {
- string Input = Console.ReadLine();
- if (Input == "end of comments") break;
- string[] DataInput = Input.Split('-').ToArray();
- string Name = DataInput[0];
- string Coment = DataInput[1];
- if (!DataDictionary.ContainsKey(Name)) continue;
- if (!ComentDictionary.ContainsKey(Name))
- {
- ComentDictionary.Add(Name, null);
- List<string> Bufera = new List<string>();
- Bufera.Add(Coment);
- ComentDictionary[Name] = Bufera;
- }
- else
- {
- ComentDictionary[Name].Add(Coment);
- }
- }
- foreach (var KVP in DataDictionary)
- {
- Console.WriteLine(KVP.Key);
- Console.WriteLine("Comments:");
- if (ComentDictionary.ContainsKey(KVP.Key))
- {
- foreach (var coment in ComentDictionary[KVP.Key])
- {
- Console.WriteLine("- " + coment);
- }
- }
- Console.WriteLine("Dates attended:");
- List<DateTime> SortedData = DataDictionary[KVP.Key].ToList();
- SortedData = SortedData.OrderBy(n => n).ToList();
- foreach (var Data in SortedData)
- {
- Console.WriteLine($"-- {Data:dd/MM/yyyy}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement