当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
2015年计算机二级C语言50套程序填空上机题(11)
发布时间:2011/11/1 9:31:06 来源:城市学习网 编辑:ziteng

  11、函数fun的功能是:把形参a所指数组中的奇数按原顺序依次存放到a[0]、a[1]、a[2]、……中,把偶数从数组中删除,奇数个数通过函数值返回。例如:若a所指数组中的数据最初排列为:9、1、4、2、3、6、5、8、7,删除偶数后a所指数组中的数据为:9、1、3、5、7,返回值为5。

  请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。

  注意:源程序存放在考生文件夹下的BLANK1.C中。

  不得增行或删行,也不得更改程序的结构!

  #include    

  #define    N    9

  int fun(int  a[], int  n)

  {  int  i,j;

     j = 0;

     for (i=0; i  /**********found**********/

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

        {

  /**********found**********/

          a[j] = a[i]; ___2___;

        }

  /**********found**********/

     return ___3___;

  }

  main()

  {  int  b[N]={9,1,4,2,3,6,5,8,7}, i, n;

     printf("\nThe original data  :\n");

     for (i=0; i     printf("\n");

     n = fun(b, N);

     printf("\nThe number of odd  : %d \n", n);

     printf("\nThe odd number  :\n");

     for (i=0; i     printf("\n");

  }

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved