Advertisement
Stan0033

Untitled

Jun 30th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace strong_number
  5. {
  6. class Program
  7. {
  8. static void Main()
  9. {
  10. static string Get() { return Console.ReadLine(); }
  11. //"{title}, {content}, {author}".
  12.  
  13.  
  14. List <Article> Articles = new List<Article>();
  15.  
  16. int NumberOfArticles = int.Parse(Console.ReadLine());
  17.  
  18. for (int i = 0; i < NumberOfArticles; i++)
  19. {
  20.  
  21.  
  22. string[] data = Get().Replace(" ", "").Split(',');
  23. Article ThisArticle = new Article();
  24. ThisArticle.title = data[0];
  25. ThisArticle.content = data[1];
  26. ThisArticle.author = data[2];
  27.  
  28. Articles.Add(ThisArticle);
  29.  
  30. }
  31. string orderBy = Get();
  32.  
  33.  
  34. switch (orderBy)
  35. {
  36. case "title": Articles = Articles.OrderBy(o => o.title).ToList(); break;
  37. case "author": Articles = Articles.OrderBy(o => o.author).ToList();break;
  38. case "content": Articles = Articles.OrderBy(o => o.content).ToList();break;
  39. }
  40.  
  41.  
  42. foreach(Article a in Articles)
  43. {
  44. Console.WriteLine($"{a.title} - {a.content}: {a.author}");
  45. }
  46. }
  47.  
  48.  
  49. }
  50. class Article
  51. {
  52. public string content { get; set; }
  53. public string author { get; set; }
  54. public string title { get; set; }
  55.  
  56. }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement