#include "stdafx.h"
#include <iostream>
using
namespace
std;
const
int
Size = 10;
void
function(
const
int
*str,
int
size);
int
main()
{
int
ch[Size];
cout <<
"Please enter ten numbers: "
<< endl;
for
(
int
x = 0; x < Size;x++)
cin >> ch[x];
function(ch,Size);
system
(
"pause"
);
return
0;
}
void
function(
const
int
*str,
int
size)
{
int
tmp;
int
j = 0,count=0;
int
c = 0;
int
temp[Size] = {0};
for
(
int
i = 0; i < size; i++)
{
if
(str[i] % 2 == 0)
{
temp[j] = str[i];
j++;
}
}
count = j;
c = j;
while
(count)
{
for
(
int
i = j-count; i < j; i++)
{
tmp = temp[j - count];
if
(tmp>=temp[i])
{
tmp = temp[i];
temp[i]=temp[j - count];
temp[j - count] = tmp;
}
}
count--;
}
for
(
int
i = 0; i < size; i++)
{
if
(str[i] % 2 == 1)
{
temp[j] = str[i];
j++;
}
}
count = j;
while
(count)
{
for
(
int
i = j - count+c; i < size; i++)
{
tmp = temp[j - count+c];
if
(tmp >= temp[i])
{
tmp = temp[i];
temp[i] = temp[j - count+c];
temp[j - count+c] = tmp;
}
}
count--;
}
for
(
int
i = 0; i < size; i++)
cout << temp[i] <<
" "
;
}