using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace 练习分拣奇数偶数
{
class Program
{
static void Main(string[] args)
{
string msg = "2 7 9 3 6 5 8 4";
string[] nums = msg.Split(' ');
//7 9 3 5 2 6 8 4
//存放奇数
ArrayList listOdd = new ArrayList();
//存放偶数
ArrayList listEven = new ArrayList();
for (int i = 0; i < nums.Length; i++)
{
if (Convert.ToInt32(nums[i]) % 2 != 0)
{
listOdd.Add(nums[i]);
}
else
{
listEven.Add(nums[i]);
}
}
listOdd.AddRange(listEven);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < listOdd.Count; i++)
{
sb.Append(listOdd[i]+" ");
}
Console.WriteLine(sb);
Console.ReadKey();
}
}
}