Advertisement
gabi11

Functional Programming - 06. Reverse And Exclude(2)

May 26th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 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.  
  8. namespace CSharpAdvanced
  9. {
  10.  
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             var numbers = Console.ReadLine()
  16.                 .Split()
  17.                 .Select(int.Parse)
  18.                 .ToList();
  19.  
  20.             int n = int.Parse(Console.ReadLine());
  21.  
  22.             Predicate<int> divisibleBy = x => x % n != 0;
  23.  
  24.             Func<IEnumerable<int>, IEnumerable<int>> reverseFunc = x => x = x.Reverse();
  25.  
  26.             Console.WriteLine(string.Join(" ", reverseFunc(numbers).Where(x => divisibleBy(x))));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement