petyaminkova91

Untitled

Nov 10th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _04Songs
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int numberOfSong = int.Parse(Console.ReadLine());
  11.  
  12. List<Song> songs = new List<Song>();
  13.  
  14. for (int i = 0; i < numberOfSong; i++)
  15. {
  16. string[] data = Console.ReadLine().Split("_");
  17.  
  18. string type = data[0];
  19. string name = data[1];
  20. string time = data[2];
  21.  
  22. Song song = new Song();
  23.  
  24. song.TypeList = type;
  25. song.Name = name;
  26. song.Time = time;
  27.  
  28. songs.Add(song);
  29. }
  30.  
  31. string typeList = Console.ReadLine();
  32.  
  33. if (typeList == "all")
  34. {
  35. foreach (var song in songs)
  36. {
  37. Console.WriteLine(song.Name);
  38. }
  39. }
  40. else
  41. {
  42. foreach (var song in songs)
  43. {
  44. if (song.TypeList == typeList)
  45. {
  46. Console.WriteLine(song.Name);
  47. }
  48. }
  49. }
  50. }
  51. }
  52.  
  53. public class Song
  54. {
  55. public string TypeList { get; set; }
  56.  
  57. public string Name { get; set; }
  58.  
  59. public string Time { get; set; }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment