作业帮 > 综合 > 作业

编写函数int fun(int *a,int n),它的功能是:把形参a所指数组中的偶数按原顺序依次存放到a[0]、a[

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/22 02:24:03
编写函数int fun(int *a,int n),它的功能是:把形参a所指数组中的偶数按原顺序依次存放到a[0]、a[1]、a[2]、……中,把奇数从数组中删除,偶数个数通过函数值返回,以-1作为有效数据的结束标志.例:若输入:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15,输出:2 4 6 8 10 12 14 n=7
这么写哪里错了:
#include
int fun(int *a,int n)
{
int i,j;
for(i=0;i
if(a[i]%2!=0)
{
for(j=i; i