Advertisement
Aborigenius

Exercise

Aug 20th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HomeWork
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.             List<Exercise> exercises = new List<Exercise>();
  15.             while (input != "go go go")
  16.             {
  17.                 string[] inputTokens = input.Split(new string[] { " -> ", }, StringSplitOptions.RemoveEmptyEntries);
  18.  
  19.                 string topic = inputTokens[0];
  20.                 string courseName = inputTokens[1];
  21.                 string judgeContestLink = inputTokens[2];
  22.                 List<string> problems = inputTokens[3].Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
  23.                 input = Console.ReadLine();
  24.  
  25.                 exercises.Add(new Exercise(topic, courseName, judgeContestLink, problems));
  26.             }
  27.             foreach (var item in exercises)
  28.             {
  29.                 Console.WriteLine($"Exercises: {item.Topic}");
  30.                 Console.WriteLine($"Problems for exercises and homework for the \"{item.CourseName}\" course @ SoftUni.");
  31.                 Console.WriteLine($"Check your solutions here: {item.JudgeContestLink}");
  32.                 int listNumber = 1;
  33.                 foreach (var exer in item.Problems)
  34.                 {
  35.                     Console.WriteLine($"{listNumber}. {exer}");
  36.                     listNumber++;
  37.                 }
  38.             }
  39.         }
  40.         class Exercise
  41.         {
  42.             public string Topic { get; set; }
  43.             public string CourseName { get; set; }
  44.             public string JudgeContestLink { get; set; }
  45.             public List<string> Problems { get; set; }
  46.  
  47.             public Exercise(string topic, string courseName, string judgeContestLink, List<string> problems)
  48.             {
  49.                 Topic = topic;
  50.                 CourseName = courseName;
  51.                 JudgeContestLink = judgeContestLink;
  52.                 Problems = problems;
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement