Advertisement
desislava_topuzakova

06. Reverse And Exclude

Jun 3rd, 2022
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ReverseAndExclude
  5. {
  6. class ReverseAndExclude
  7. {
  8. static void Main(string[] args)
  9. {
  10. Action<int[]> reverse = i =>
  11. {
  12. for (int j = 0; j < i.Length/2; j++)
  13. {
  14. int temp = i[j];
  15. i[j] = i[i.Length - 1 - j];
  16. i[i.Length - 1 - j] = temp;
  17. }
  18. };
  19. int[] numbers = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  20. int n = int.Parse(Console.ReadLine());
  21. Predicate<int> filter = i => i % n != 0;
  22. reverse(numbers);
  23. Console.WriteLine(string.Join(" ", numbers.ToList().FindAll(filter)));
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement