6-3 统计数组中偶数的个数
分数 15
作者 李军
单位 陕西理工大学
编写函数,统计整数数组中偶数的个数。函数的接口定义如下:
函数接口定义:
int EvenStatistics(int *p, int n);
p是指向数组的指针, n 是数组中元素的个数。函数的返回值是统计结果。
裁判测试程序样例:
#include <stdio.h>
void InputArray(int *p,int n)
{
for(int i=0;i<n;i++,p++)
scanf("%d",p);
}
/* 你编写的函数放在这里 */
int main()
{
int n;
scanf("%d",&n);
int a[n];
InputArray(a,n);
printf("Even = %d\n",EvenStatistics(a,n));
return 0;
}
输入样例:
10
8 5 0 1 2 3 4 6 7 9
输出样例:
Even = 5
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB