Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace strong_number
- {
- class Program
- {
- static void Main()
- {
- static string Get() { return Console.ReadLine(); }
- //"{title}, {content}, {author}".
- List <Article> Articles = new List<Article>();
- int NumberOfArticles = int.Parse(Console.ReadLine());
- for (int i = 0; i < NumberOfArticles; i++)
- {
- string[] data = Get().Replace(" ", "").Split(',');
- Article ThisArticle = new Article();
- ThisArticle.title = data[0];
- ThisArticle.content = data[1];
- ThisArticle.author = data[2];
- Articles.Add(ThisArticle);
- }
- string orderBy = Get();
- switch (orderBy)
- {
- case "title": Articles = Articles.OrderBy(o => o.title).ToList(); break;
- case "author": Articles = Articles.OrderBy(o => o.author).ToList();break;
- case "content": Articles = Articles.OrderBy(o => o.content).ToList();break;
- }
- foreach(Article a in Articles)
- {
- Console.WriteLine($"{a.title} - {a.content}: {a.author}");
- }
- }
- }
- class Article
- {
- public string content { get; set; }
- public string author { get; set; }
- public string title { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement