Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _3._Articles_2._0
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Article> articles = new List<Article>();
- int count = int.Parse(Console.ReadLine());
- for (int i = 0; i < count; i++)
- {
- string[] input = Console.ReadLine().Split(", ");
- string title = input[0];
- string content = input[1];
- string author = input[2];
- Article article = new Article(title, content, author);
- articles.Add(article);
- }
- string data = Console.ReadLine();
- if (data == "title")
- {
- articles = articles.OrderBy(x => x.Title).ToList();
- foreach (var article in articles)
- {
- Console.WriteLine($"{article.Title} - {article.Content}: {article.Author}");
- }
- }
- else if (data == "content")
- {
- articles = articles.OrderBy(x => x.Content).ToList();
- foreach (var article in articles)
- {
- Console.WriteLine($"{article.Title} - {article.Content}: {article.Author}");
- }
- }
- else if (data == "author")
- {
- articles = articles.OrderBy(x => x.Author).ToList();
- foreach (var article in articles)
- {
- Console.WriteLine($"{article.Title} - {article.Content}: {article.Author}");
- }
- }
- }
- class Article
- {
- public string Title { get; set; }
- public string Content { get; set; }
- public string Author { get; set; }
- public Article(string title, string content, string author)
- {
- this.Title = title;
- this.Content = content;
- this.Author = author;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement