Guest User

Untitled

a guest
Oct 12th, 2016
586
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. else dict[tit] = relD;
  28. }
  29.  
  30. foreach (var item in dict.OrderBy(x => x.Value).ThenBy(y => y.Key))
  31. {
  32. var D = item.Value.Date;
  33. if (item.Value > date) Console.WriteLine("{0} -> {1:d.MM.yyyy}", item.Key, D);
  34. }
  35. }
  36. static Book ReadBook()
  37. {
  38. var book = new Book();
  39. string[] args = Console.ReadLine().Split(' ');
  40. book.title = args[0];
  41. book.relDate = DateTime.ParseExact(args[3], "d.M.yyyy", CultureInfo.InvariantCulture);
  42. return book;
  43. }
  44. static Library ReadAllBooks()
  45. {
  46. var libraray = new Library();
  47. libraray.Books = new List<Book>();
  48. int n = int.Parse(Console.ReadLine());
  49. for (int i = 0; i < n; i++)
  50. {
  51. var book = ReadBook();
  52. libraray.Books.Add(book);
  53. }
  54. return libraray;
  55. }
  56. }
  57. class Book
  58. {
  59. public string title { get; set; }
  60. public string author { get; set; }
  61. public string publisher { get; set; }
  62. public DateTime relDate { get; set; }
  63. public string ISBN { get; set; }
  64. public decimal price { get; set; }
  65. }
  66. class Library
  67. {
  68. public string Name { get; set; }
  69. public List<Book> Books { get; set; }
  70. }
  71. }
RAW Paste Data