static void Main(string[] args) { Func <string, int> Parser = n => int.Parse(n); int[] Numbers = Console.ReadLine() .Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries) .Select(Parser) .ToArray(); Func <int[], int[]> Sorter = n => { //Taking the even numbers int[] EvenNumbers; EvenNumbers = n.Where(w => w % 2 == 0).OrderBy(x => x).ToArray(); //Taking the odd numbers int[] OddNumbers; OddNumbers = n.Where(p => p % 2 != 0).OrderBy(x => x).ToArray(); //Combinin them int[] CombinedArr = EvenNumbers.Concat(OddNumbers).ToArray(); return(CombinedArr); }; Console.WriteLine(string.Join(" ", Sorter(Numbers))); }
public void EvenShouldPrintFirstNumber() { EvenNumbers even = new EvenNumbers(); int expected = 2; int actual = even.GetFirst(); Assert.AreEqual(expected, actual); }
public void EvenPrintSequenceofNumbers() { EvenNumbers even = new EvenNumbers(); int length = 7; string expected = "2 4 6 8 10 12 14"; string actual = even.ToString(even.GetSequence(length)); Assert.AreEqual(expected, actual); }
public void EvenShouldPrintVariableSequenceOfNumbers() { EvenNumbers even = new EvenNumbers(); int input = 8; int[] expected = new int[] { 2, 4, 6, 8, 10, 12, 14, 16 }; int[] actual = even.GetSequence(input); CollectionAssert.AreEqual(expected, actual); }
public void EvenShouldPrintNextNumber() { EvenNumbers even = new EvenNumbers(); int input = 2; int expected = 4; int actual = even.GetNext(input); Assert.AreEqual(expected, actual); }
static void Main(string[] args) { ISequence t = new EvenNumbers(); Console.WriteLine("Event Numbers!"); t.getsequence(10).ForEach(x => Console.WriteLine(x)); Console.WriteLine("Fibonacci Numbers!"); t = new Fibonaccinumbers(); t.getsequence(10).ForEach(x => Console.WriteLine(x)); }
public void EvenEnsureICanCreateClassInstance() { EvenNumbers even = new EvenNumbers(); Assert.IsNotNull(even); }