微信搜索关注"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: %s\n",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 =%f\n",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("%d\n", fun (x, 8));
}
三、程序编写题
#include <stdio.h>
float fun(int m, int n)
{
}
main() /* 主函数 */
{ void NONO ();
printf("P=%f\n", 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, "%f\n", s) ;
}
fclose(fp) ;
fclose(wf) ;
}