编程程序,从键盘输入10个整数给一维数组a[10], 统计数组元素中奇数和偶数个数

如题所述

//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
    int even,odd,a[10],i;
    for(even=odd=i=0;i<10;i++)
        if(scanf("%d",a+i) && a[i]&1)
            odd++;
        else even++;
    printf("EVEN = %d\nODD = %d\n",even,odd);
    return 0;
}

不过这题实在用不着那个数组,但题有要求,所以写上了……

温馨提示:答案为网友推荐,仅供参考