Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace classes
- {
- class Songs
- {
- public string TypeList { get; set; }
- public string Name { get; set; }
- public string Time { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int songsCount = int.Parse(Console.ReadLine());
- List<Songs> list = new List<Songs>();
- for (int i = 0; i < songsCount; i++)
- {
- string[] input = Console.ReadLine().Split("_").ToArray();
- string type = input[0];
- string name = input[1];
- string time = input[2];
- Songs song = new Songs();
- song.TypeList = type;
- song.Name = name;
- song.Time = time;
- list.Add(song);
- }
- string filter = Console.ReadLine();
- if (filter == "all")
- {
- foreach (var song in list)
- {
- Console.WriteLine(song.Name);
- }
- }
- else
- {
- List<Songs> filtered = list.Where(x => x.TypeList == filter).ToList();
- foreach (var song in filtered)
- {
- Console.WriteLine(song.Name);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement