Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04._FindEvensOrOdds
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<long> input = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToList();
- long down = input.Min();
- long top = input.Max();
- string condition = Console.ReadLine();
- List<long> nums = new List<long>();
- for (long i = down; i <= top; i++)
- {
- nums.Add(i);
- }
- Predicate<long> even = x => { return x % 2 == 0; };
- Predicate<long> odd = x => { return x % 2 == 1; };
- if (condition == "even")
- {
- Console.WriteLine(string.Join(" ", nums.FindAll(even)));
- }
- else
- {
- Console.WriteLine(string.Join(" ", nums.FindAll(odd)));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement