Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - The function of c++ to judge fun(a) is to count the number of even elements in plastic array A and use it as the return value of this function.
The function of c++ to judge fun(a) is to count the number of even elements in plastic array A and use it as the return value of this function.
# include & ltiostream & gt

Use namespace std

size_t fun(int* a,int n)

{

size _ t size = 0;

for(int I = 0; I & ltn;; ++i)

if(a[i] % 2 == 0)

++size;

Returns the size;

}

int main()

{

int n;

Cout & lt& lt "Array size:"

CIN & gt; & gtn;

If (n < = 0)

Returns1;

int a[n];

for(int I = 0; I & ltn;; ++i)

CIN & gt; & gta[I];

size_t size = fun(a,n);

Cout & lt& lt size & lt& ltendl

Returns 0;

}