TOP

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

29套题

一、程序填空题

#include  <stdio.h>

double fun(double  e)

{ int  i;    double  s, x;

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

  s=0;  i=__1__;

  x=1.0;

  while(x>e){

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

    __2__;

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

    x=(2.0*i-1)/((__3__)*(2.0*i));

    s=s+x;

  }

  return  s;

}

main()

{ double  e=1e-3;

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

}

 

 

二、程序改错题

#include <stdio.h>

#include <string.h>

 

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

void fun (char  s, char  t)

{

  int   i, d;

  d = strlen(s);

  for (i = 0; i<d; i++)  t[i] = s[i];

  for (i = 0; i<d; i++)  t[d+i] = s[d-1-i];

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

  t[2*d-1] = '\0';

}

 

main()

{

  char   s[100], t[100];

  printf("\nPlease enter string S:"); scanf("%s", s);

  fun(s, t);

  printf("\nThe result is: %s\n", t);

}

 

 

三、程序编写题

#include <stdio.h>

#include <string.h>

 

void fun(char *s, char t[])

{

 

 

 

 

}

 

main()

{

  char   s[100], t[100];void NONO ();

  printf("\nPlease enter string S:"); scanf("%s", s);

  fun(s, t);

  printf("\nThe result is: %s\n", t);

  NONO();

}

 

void NONO ()

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

  char s[100], t[100] ;

  FILE *rf, *wf ;

  int i ;

 

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

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

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

    fscanf(rf, "%s", s) ;

    fun(s, t) ;

    fprintf(wf, "%s\n", t) ;

  }

  fclose(rf) ;

  fclose(wf) ;

}

 

 

 

 

 

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

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117