TOP

2012全国计算机二级C语言(C++)题库 第33套题
2011-12-25 00:32:36 来源: 作者: 【 】 浏览:134次 评论:0
微信搜索关注"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]=%d\n",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("\n\n");

  }

  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 %lf\n", 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) ;

}

 

 

 

Tags: 责任编辑:91kaoshiwang
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇2012全国计算机二级C语言(C++)题.. 下一篇2012全国计算机二级C语言(C++)题..

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117