2012全国计算机二级C语言(C++)题库 第33套题

时间:2011-12-25 00:32:36

微信搜索关注"91考试网"公众号,领30元,获取事业编教师公务员等考试资料40G

33套题

一、程序填空题

#include  <stdio.h>

#define   M   3

#define   N   4

void fun(int  (*a)[N])

{ int  i=0,j,find=0,rmax,c,k;

  while( (i<M) && (!find))

  {  rmax=a[i][0];  c=0;

     for(j=1; j<N; j++)

       if(rmax<a[i][j]) {

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

         rmax=a[i][j]; c= __1__ ; }

     find=1; k=0;

     while(k<M && find) {

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

       if (k!=i && a[k][c]<=rmax)  find= __2__ ;

       k++;

     }

     if(find) printf("find: a[%d][%d]=%dn",i,c,a[i][c]);

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

      __3__ ;

  }

  if(!find) printf("not found!n");

}

main()

{ int  x[M][N],i,j;

  printf("Enter number for array:n");

  for(i=0; i<M; i++)

    for(j=0; j<N; j++) scanf("%d",&x[i][j]);

  printf("The array:n");

  for(i=0; i<M; i++)

  {  for(j=0; j<N; j++) printf("%3d",x[i][j]);

     printf("nn");

  }

  fun(x);

}

 

 

二、程序改错题

#include <stdio.h>

 

double fun ( int m )

{  double   y = 1.0 ;

   int  i ;

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

   for(i = 2 ; i < m ; i++)

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

      y -= 1 /(i * i) ;

   return( y ) ;

}

 

main( )

{  int n = 5 ;

 

   printf( "nThe result is %lfn", fun ( n ) ) ;

}

 

 

三、程序编写题

#include <stdio.h>

#include <string.h>

int fun(int score[], int m, int below[])

{

 

 

 

 

 

}

 

main( )

{  int i, n, below[9] ;void NONO ();

   int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90} ;

 

   n = fun(score, 9, below) ;

   printf( "nBelow the average score are: " ) ;

   for (i = 0 ; i < n ; i++)  printf("%d ", below[i]) ;

   NONO() ;

}

 

void NONO ()

{/* 本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/

  int i, j, n, below[10], score[10] ;

  FILE *rf, *wf ;

 

  rf = fopen("K:\k01\24010001\in.dat","r") ;

  wf = fopen("K:\k01\24010001\out.dat","w") ;

  for(i = 0 ; i < 10 ; i++) {

    for(j = 0 ; j < 10 ; j++) fscanf(rf, "%d", &score[j]) ;

    n = fun(score, 10, below) ;

    for(j = 0 ; j < n ; j++) fprintf(wf, "%d ", below[j]) ;

    fprintf(wf, "n") ;

  }

  fclose(rf) ;

  fclose(wf) ;

}

 

 

 


微信搜索关注"91考试网"公众号,领30元,获取公务员事业编教师考试资料40G
【省市县地区导航】【考试题库导航】

电脑版  |  手机版  |  返回顶部