将一个数组拆分为一个为奇数数组,一个为偶数数组
#include <stdio.h>
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
int i[10],j[10];
int b,c,d;
c=d=0;
for(b=0;b<10;b++)
{
if(a[b]%2==0)
{
i[c]=a[b];
c++;
}
else
{
j[d]=a[b];
d++;
}
}
printf("原数组: ");
for(b=0;b<10;b++)
{
printf("%d ",a[b]);
}
printf("\n 偶数:");
for(b=0;b<c;b++)
{
printf("%d ",i[b]);
}
printf("\n 奇数:");
for(b=0;b<d;b++)
{
printf("%d ",j[b]);
}
return 0;
}
标签:10,奇数,int,偶数,一个,数组
From: https://www.cnblogs.com/yesiming/p/17467605.html