#include<stdio.h>
#define N 9
int fun (int a[], int n)
{
int i, j;
j=0;
for (i=0; i<n; i++)
/**********found**********/
if (a[i]%2== 1)
{
/**********found**********/
a[j]=a[i];
j++;
}
/**********found**********/
return j;
}
main( )
{
int b[N]={
9,1,4,2,3,6,5,8,7}, i, n;
printf("\nThe original data:\n");
for(i=0; i<N; i++)
printf("% 4d", b[i]);
printf("\n");
n=fun(b, N);
printf("\nThe number of odd:% d\n", n);
printf("\nThe odd number: \n");
for(i=0; i<n; i++)
printf("%4d",b[i]);
printf("\n");
}
请编写函数int funint a,int n,它的功能是把形参a所指数组中的偶数按原顺序依次存放到a0a1a2中,把奇数从数组中删除,偶数个数通过函数值返回,以-1作为有效数据的结束标志例若输入1
猜你喜欢
转载自blog.csdn.net/weixin_44517301/article/details/109103237
今日推荐
周排行