Guest User

Untitled

a guest
Feb 7th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace E07.PredicateForNames
  5. {
  6.     public class StartUp
  7.     {
  8.         public static void Main()
  9.         {
  10.             int charCount = int.Parse(Console.ReadLine());
  11.  
  12.             Func<string, bool> myFunc = x => x.Length <= charCount;
  13.  
  14.             var names = Console.ReadLine()
  15.                 .Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)
  16.                 .OrderBy(n => n.Length)
  17.                 .Where(n=>myFunc(n))
  18.                 .ToList();
  19.  
  20.             names.ForEach(Console.WriteLine);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment