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

  13、人员的记录由编号和出生年、月、日组成,N名人员的数据已在主函数中存入结构体数组std中。函数fun的功能是:找出指定出生年份的人员,将其数据放在形参k所指的数组中,由主函数输出,同时由函数值返回满足指定条件的人数。

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

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

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

  #include    

  #define    N    8

  typedef  struct

  {  int  num;

     int  year,month,day ;

  }STU;

  int fun(STU  *std, STU  *k, int  year)

  {  int  i,n=0;

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

        if(  ___1___==year)

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

           k[n++]= ___2___;

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

     return (___3___);

  }

  main()

  {  STU  std[N]={ {1,1984,2,15},{2,1983,9,21},{3,1984,9,1},{4,1983,7,15},

                   {5,1985,9,28},{6,1982,11,15},{7,1982,6,22},{8,1984,8,19}};

     STU  k[N];         int  i,n,year;

     printf("Enter a year :  ");  scanf("%d",&year);

     n=fun(std,k,year);

     if(n==0)

        printf("\nNo person was born in %d \n",year);

     else

     {   printf("\nThese persons were born in %d \n",year);

         for(i=0; i           printf("%d  %d-%d-%d\n",k[i].num,k[i].year,k[i].month,k[i].day);

     }

  }

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