yanchevilian

06. Reverse and Exclude / Functional Programming

Sep 7th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _6._Reverse_and_Exclude
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Func<List<int>, int, List<int>> func = (collection, divider) =>
  12.             {
  13.                 return collection = collection.Where(number => number % divider != 0).ToList();
  14.             };
  15.             List<int> numbers = new List<int>(Console.ReadLine().Split().Select(int.Parse).Reverse());
  16.             int divider = int.Parse(Console.ReadLine());
  17.  
  18.             Action<List<int>> printCollection = collection => Console.WriteLine(string.Join(" ", collection));
  19.             numbers = func(numbers, divider);
  20.             printCollection(numbers);
  21.         }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment