Idea: Traverse the array, determine whether it is divisible by 2, determine whether it is an odd number or an even number, and make statistics, and finally count the odd and even numbers.
Reference code: #include
#include
int?main() { int?i,j= 0,o=0,a[10]={0,1,2,3,4,5,6,7,8,9}; for(i=0;i<10;i++) if(a[i ]%2)?j++; else?o++; printf("There are %d odd numbers and %d even numbers.\n",j,o);
return?0; }
/*
Running results:
There are 5 odd numbers and 5 even numbers.
*/