using System;
public class Program
{
public static void Main()
int[] numbers = {5,2,14,-17,99,100,24,26,11,9,16,29,900,7,45,4};
int newLen = 0;
int firstEmpty = -1;
for(int i = 0; i < numbers.Length; i++)
if(Math.Abs(numbers[i])%2 > 0)
if(firstEmpty == -1)
firstEmpty = i;
}
//if you want to eliminate odd from the original array (post newLen), you can set numbers[i] to "null" here
else
newLen++;
if(firstEmpty > -1)
numbers[firstEmpty] = numbers[i];
firstEmpty++;
//here you're "swapping" with the first empty position, but it's not technically necessary. You can do it to eliminate the duplicate even number from the original array (post newLen)
for(int i=0; i<newLen;i++)
Console.Write(numbers[i].ToString() + " ") ;