#include<stdio.h> #define N 9 int fun(int a[],int n) { int i,j=0; for(i=0;i<n;i++) if(a[i]%2==0) { a[j]=a[i]; j++; } return j; } main() { int b[N]={9,7,5,3,4,6,8,2,1},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 nuber :\n"); for(i=0;i<n;i++) printf("%4d",b[i]); printf("\n"); }
时间: 2024-10-05 19:45:23