Advertisement
Grimmjow1

Untitled

Jul 10th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 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 songs
  8. {
  9.    public class Song
  10.     {
  11.        public string name { get; set; }
  12.        public  string typeList { get; set; }
  13.        public string time { get; set; }
  14.  
  15.     }
  16.     class Program
  17.     {
  18.         static void Main(string[] args)
  19.         {
  20.             int n = int.Parse(Console.ReadLine());
  21.             List<Song>list= new List<Song>();
  22.             for (int i = 0; i < n; i++)
  23.             {
  24.                 string[] input = Console.ReadLine().Split('_').ToArray();
  25.  
  26.                 string type = input[0];
  27.                 string name  = input[1];
  28.                 string time = input[2];
  29.                 Song song = new Song
  30.                 {
  31.                     name = name,
  32.                     typeList = type,
  33.                     time = time
  34.  
  35.                 };
  36.                 list.Add(song);
  37.             }
  38.             string type1 = Console.ReadLine();
  39.             if (type1=="all")
  40.             {
  41.                 foreach (var item in list)
  42.                 {
  43.                     Console.WriteLine(item.name);
  44.                 }
  45.             }
  46.             List<Song> newlist = list.Where(x => x.typeList == type1).ToList();
  47.  
  48.             for (int i = 0; i < newlist.Count; i++)
  49.             {
  50.                 Console.WriteLine(newlist[i].name);
  51.             }
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement