Guest User

Untitled

a guest
Oct 12th, 2016
209
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Numerics;
  8.  
  9. namespace MyProgram
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. var lib = ReadAllBooks();
  16. var books = lib.Books;
  17.  
  18. var dict = new Dictionary<string, DateTime>();
  19. string inn = Console.ReadLine();
  20. DateTime date = DateTime.ParseExact(inn, "d.M.yyyy", CultureInfo.InvariantCulture);
  21.  
  22. foreach (var item in books)
  23. {
  24. var tit = item.title;
  25. var relD = item.relDate;
  26. if (!dict.ContainsKey(tit)) dict.Add(tit, relD);
  27. }
  28.  
  29. foreach (var item in dict.OrderBy(x => x.Value).ThenBy(y => y.Key))
  30. {
  31. var D = item.Value.Date;
  32. if (item.Value > date) Console.WriteLine("{0} -> {1:d.MM.yyyy}", item.Key, D);
  33. }
  34. }
  35. static Book ReadBook()
  36. {
  37. var book = new Book();
  38. string[] args = Console.ReadLine().Split(' ');
  39. book.title = args[0];
  40. book.relDate = DateTime.ParseExact(args[3], "d.M.yyyy", CultureInfo.InvariantCulture);
  41. return book;
  42. }
  43. static Library ReadAllBooks()
  44. {
  45. var libraray = new Library();
  46. libraray.Books = new List<Book>();
  47. int n = int.Parse(Console.ReadLine());
  48. for (int i = 0; i < n; i++)
  49. {
  50. var book = ReadBook();
  51. libraray.Books.Add(book);
  52. }
  53. return libraray;
  54. }
  55. }
  56. class Book
  57. {
  58. public string title { get; set; }
  59. public string author { get; set; }
  60. public string publisher { get; set; }
  61. public DateTime relDate { get; set; }
  62. public string ISBN { get; set; }
  63. public decimal price { get; set; }
  64. }
  65. class Library
  66. {
  67. public string Name { get; set; }
  68. public List<Book> Books { get; set; }
  69. }
  70. }
RAW Paste Data