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

时间:2011-12-25 00:37:59

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

37套题

一、程序填空题

#include  <stdio.h>

int fun(char  *s, char  *t)

{ int  n=0;

  while(*s)

  { if(*s < 97) {

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

     *(t+n)= __1__ ;  n++;  }

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

     __2__ ;

  }

  *(t+n)=0;

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

  return  __3__ ;

}

main()

{ char  s[81],t[81];    int  n;

  printf("nEnter a string:n");  gets(s);

  n=fun(s,t);

  printf("nThere are %d letter which ASCII code is less than 97: %sn",n,t);

}

 

 

二、程序改错题

#include <stdio.h>

 

int fun(double x[], int n)

{

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

  int j, c=0, double xa=0.0;

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

     xa += x[j]/n;

   printf("ave =%fn",xa);

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

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

     if (x[j] => xa)

       c++;

   return c;

}

 

main ( )

{  double x[100] = {193.199, 195.673, 195.757, 196.051, 196.092, 196.596, 196.579, 196.763};

   printf("%dn", fun (x, 8));

}

 

 

三、程序编写题

#include <stdio.h>

float  fun(int m, int n)

{

 

 

 

}

 

main()   /* 主函数 */

{  void NONO ();

   printf("P=%fn", fun (12,8));

   NONO();

}

 

void NONO ()

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

  FILE *fp, *wf ;

  int i, m, n ;

  float 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,%d", &m, &n) ;

    s = fun(m, n) ;

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

  }

  fclose(fp) ;

  fclose(wf) ;

}

 


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

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