#include <stdio.h>
#include <stdlib.h>
int judge(int a);
int testsrry[10] = {1,242,0,5,34,67,32,12,34,3};
void swap(int *a,int b);
/ run this program using the console pauser or add your own getch, system(“pause”) or input loop */
void ajust(int a[],int subscript);
int main(int argc, char *argv[]) {
ajust(testsrry,9);
int i = 0;
for(i;i<10;i++)
{
printf("%d ",testsrry[i]);
}
return 0;
}
int judge(int a)
{
if((a%2)==0)
{
return 1;
}
else {
return 0;
}
}
void ajust(int a[],int subscript)
{
int i = subscript;
int j = 0;
for(i;i>=1;i–)
{
if(judge(a[i])==1)
{
for(j = 0;j<i;j++)
{
if(judge(a[j])==0)//如果能从0到i-1内找到一个奇数,将奇数偶数交换
{
swap(&a[i],&a[j]);
}
}
j = 0;
}
}
}
void swap(int *a,int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}