Advertisement
gabi11

Functional Programming - 07. Predicate For Names

May 28th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace Advanced
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             var names = Console.ReadLine().Split();
  16.  
  17.             Predicate<string> condition = x => x.Length <= n;
  18.  
  19.             foreach (var name in names)
  20.             {
  21.                 if (condition(name))
  22.                 {
  23.                     Console.WriteLine(name);
  24.                 }
  25.             }
  26.         }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement