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 Book_Library
- {
- public class Book
- {
- public string Title { get; set; }
- public string Author { get; set; }
- public string Publisher { get; set; }
- public string ReleaseDate { get; set; }
- public string ISBN { get; set; }
- public decimal Price { get; set; }
- }
- public class Library
- {
- public string Name { get; set; }
- public List<Book> Books {get;set;}
- public Library()
- {
- Books = new List<Book>();
- }
- }
- public class Program
- {
- public static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Library Library = new Library();
- Dictionary<string, decimal> dict = new Dictionary<string, decimal>();
- for (int i = 0; i < n; i++)
- {
- Book currentBook = new Book();
- var input = Console.ReadLine().Split().ToArray();
- currentBook.Title = input[0];
- currentBook.Author = input[1];
- currentBook.Publisher = input[2];
- currentBook.ReleaseDate = input[3];
- currentBook.ISBN = input[4];
- currentBook.Price =decimal.Parse( input[5]);
- Library.Books.Add(currentBook);
- if (!dict.Keys.Contains(Library.Books[i].Author))
- {
- dict.Add(Library.Books[i].Author, currentBook.Price);
- }
- else
- {
- dict[Library.Books[i].Author] += currentBook.Price;
- }
- }
- foreach (var item in dict.OrderBy(x=>-x.Value).ThenBy(x=>x.Key))
- {
- Console.WriteLine("{0} -> {1}",item.Key,item.Value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment