Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _02._List_Of_Even_Numbers
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine(); //"3 4 8 5 7 5 2 1"
- List<int> numbers = input.Split(" ") //["3", "4", "8", "5", "7", "5", "2", "1"]
- .Select(int.Parse) // [3, 4, 8, 5, 7, 5, 2, 1]
- .ToList(); // {3, 4, 8, 5, 7, 5, 2, 1}
- foreach (int number in numbers)
- {
- if (number % 2 == 0)
- {
- Console.Write(number + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement