Advertisement
dxeqtr

Untitled

Jan 8th, 2021
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _08.EvenNumbers
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string str = Console.ReadLine();
  11.  
  12. str = str.Remove(str.Trim().Length - 1);
  13.  
  14. string[] input = str
  15. .Split()
  16. .ToArray();
  17.  
  18. int[] result = input
  19. .Where(x => x.All(char.IsDigit))
  20. .Select(int.Parse)
  21. .Where(x => x % 2 == 0)
  22. .ToArray();
  23.  
  24. if (result.Length == 0)
  25. {
  26. Console.WriteLine(-1);
  27. }
  28. else
  29. {
  30. int number = result
  31. .Max();
  32. Console.WriteLine(number);
  33. }
  34.  
  35. }
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement