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

时间:2011-12-25 00:14:29

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

 

20套题

一、程序填空题

#include    <stdio.h>

#define    N    4

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

{  int  j ,r[N];

   for(j=0; j<N; j++)  r[j]=t[0][j];

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

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

      t[0][N-j-1]=t[j][___1___ ];

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

      t[j][0]=t[N-1][j];

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

   for(j=N-1; j>=0;___2___ )

      t[N-1][N-1-j]=t[j][N-1];

   for(j=N-1; j>=0; j--)

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

      t[j][N-1]=r[___3___];

}

main()

{  int t[][N]={21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10}, i, j;

   printf("nThe original array:n");

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

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

      printf("n");

   }

   fun(t);

   printf("nThe result is:n");

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

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

      printf("n");

   }

}

 

 

二、程序改错题

#include <stdio.h>

#include <math.h>

 

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

f( double x)

{

   if (x == 0.0 || x == 2.0)

     return 0.0;

   else if (x < 0.0)

     return (x -1)/(x-2);

   else

     return (x +1)/(x-2);

}

 

double fun(  int  n )

{  int i;  double   s=0.0, y;

   for (i= -n; i<=n; i++)

    {y=f(1.0*i); s += y;}

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

   return s

}

 

main ( )

{

   printf("%fn", fun(5) );

}

 

 

三、程序编写题

#include <math.h>

#include <stdio.h>

double   fun(  int  m )

{

 

 

 

}

 

main()

{

   void NONO (  );

   printf("%fn", fun(20));

   NONO();

}

 

void NONO (  )

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

  FILE *fp, *wf ;

  int i, n ;

  double s ;

 

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

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

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

    fscanf(fp, "%d", &n) ;

    s = fun(n) ;

    fprintf(wf, "%fn", s) ;

  }

  fclose(fp) ;

  fclose(wf) ;

}

 

 


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

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