forked from Atis0505/pallida-basic-exam-trial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOddFilter.cs
28 lines (24 loc) · 767 Bytes
/
OddFilter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
namespace OddFilter
{
class Program
{
static void Main(string[] args)
{
// Create an OddFilter function that takes a list as a parameter,
// and returns a new list with every odd element from the orignal list
List<int> oddElements = OddFilter(new List<int> { 1, 2, 3, 4, 5 });
// In case of the example input above, the given PrintList function should print 1 3 5
PrintList(oddElements);
Console.ReadLine();
}
private static void PrintList(List<int> list)
{
foreach (int element in list)
{
Console.Write("{0} ", element);
}
}
}
}