TOP

2012全国计算机二级C语言(C++)题库 第28套题
2011-12-25 00:26:07 来源: 作者: 【 】 浏览:131次 评论:0
微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!

28套题

一、程序填空题

#include  <stdio.h>

double fun(double  e)

{ int  i, k;    double  s, t, x;

  s=0;  k=1;  i=2;

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

  x=__1__/4;

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

  while(x __2__ e)

  { s=s+k*x;

    k=k* (-1);

    t=2*i;

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

    x=__3__/(t*t);

    i++;

  }

  return  s;

}

main()

{ double  e=1e-3;

  printf("\nThe result is: %f\n",fun(e));

}

 

 

二、程序改错题

#include <stdio.h>

 

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

void fun (  int  n )

{   int  a, b, c, k;  double  s;

    s = 0.0;  a = 2;  b = 1;

    for ( k = 1; k <= n; k++ ) {

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

      s = s + (Double)a / b;

       c = a;  a = a + b; b = c;

    }

    return s;

}

 

main( )

{   int   n = 5;

    printf( "\nThe value of  function is: %lf\n",  fun (  n ) );

}

 

 

三、程序编写题

#include <stdio.h>

#define M 4

int fun (int a[][M])

{

 

 

 

}

 

main( )

{  int arr[2][M]={5,8,3,45,76,-4,12,82} ;void NONO ();

   printf("max =%d\n", fun(arr)) ;

   NONO( ) ;

}

 

void NONO ()

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

  FILE *wf ;

  int arr[][M]={5,8,3,90,76,-4,12,82} ;

 

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

  fprintf(wf, "max=%d\n", fun(arr)) ;

  fclose(wf) ;

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

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117