JulianJulianov

18.TextProcessingMoreExercise-HTML

Apr 26th, 2020
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. 05. HTML
  2. You will receive 3 lines of input. On the first line you will receive a title of an article. On the next line you will receive the content of that article. On the next n lines until you receive "end of comments" you will get the comments about the article. Print the whole information in html format. The title should be in "h1" tag (<h1></h1>); the content in article tag (<article></article>); each comment should be in div tag (<div></div>). For more clarification see the example below
  3. Example
  4. Input                                                Output
  5. SoftUni Article                                      <h1>
  6. Some content of the SoftUni article                      SoftUni Article
  7. some comment                                         </h1>
  8. more comment                                         <article>
  9. last comment                                             Some content of the SoftUni article
  10. end of comments                                      </article>
  11.                                                      <div>
  12.                                                          some comment
  13.                                                      </div>
  14.                                                      <div>
  15.                                                          more comment
  16.                                                      </div>
  17.                                                      <div>
  18.                                                          last comment
  19.                                                      </div>
  20.    
  21. using System;
  22. using System.Collections.Generic;
  23.  
  24. public class Program
  25. {
  26.     public static void Main()
  27.     {
  28.          var titleOfArticle = Console.ReadLine();
  29.          var contentOfArticle = Console.ReadLine();
  30.  
  31.           var listOfComments = new List<string>();
  32.           var commentsOfArticle = "";
  33.           while ((commentsOfArticle = Console.ReadLine()) != "end of comments")
  34.           {
  35.               listOfComments.Add(commentsOfArticle);
  36.           }
  37.           Console.WriteLine($"<h1>\n    {titleOfArticle}\n</h1>\n<article>\n    {contentOfArticle}\n</article>");
  38.           Console.WriteLine($"<div>\n    {string.Join("\n</div>\n<div>\n    ", listOfComments)}\n</div>");
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment