#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int total=0,i,h;
int x[21];

int countEven(int*a, int len){
    srand( time( NULL ) );
    for(i=0;i<20;i++){
        x[i]=rand()%1000;
        printf("%4d",x[i]);
    }
    *a=x[0];
    while(*a++){
        if(*a%2==0) {
            total++;
            }   
    }
    return total;
}

int main( void ){
    countEven(x,20);
    printf("There are %d even integers in the data.\n",total);
    return 0;
}
 

//這題檸檬想了好久,堅持下去果然就成功了

//題目來源:c how to program

//程式均為自創,如有雷同純屬巧合

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 檸檬 的頭像
    檸檬

    檸檬的C語言初學日誌

    檸檬 發表在 痞客邦 留言(0) 人氣()