1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include<stdio.h>
void main(void)
{
int NumList[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
int oddNum[10], evenNum[10];
int i,n=0;
int even=0,odd=0;
for(i=0;i<20;i++)
{
if(NumList[i]% 2 == 0)
{
evenNum[i] = n;
++even;
}
else
{
oddNum[i] = n;
++odd;
}
}
printf("Even numbers: ");
for(even = 0; even < 10; ++even)
{
if(evenNum[even] < 1)
{
break;
}
else
{
printf("%d ",evenNum[even]);
}
}
printf("\nOdd numbers: ");
for(odd = 0; odd < 10; ++odd)
{
if(oddNum[odd] < 1)
{
break;
}
else
{
printf("%d ",oddNum[odd]);
}
}
}
|