微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!
第14套题
一、程序填空题
#include <stdio.h>
void fun(char *s, int *t)
{ int i, n;
n=0;
/**********found**********/
for(i=0; ___1___ !=0; i++)
/**********found**********/
if(s[i]>='0'&&s[i]<= ___2___ ) n++;
/**********found**********/
___3___ ;
}
main()
{ char s[80]="abcdef35adgh3kjsdf7";
int t;
printf("\nThe original string is : %s\n",s);
fun(s,&t);
printf("\nThe result is : %d\n",t);
}
二、程序改错题
#include <stdio.h>
int fun(int *x,int y)
{
int t ;
/**************found**************/
t = x ; x = y ;
/**************found**************/
return(y) ;
}
main()
{
int a = 3, b = 8 ;
printf("%d %d\n", a, b) ;
b = fun(&a, b) ;
printf("%d %d\n", a, b) ;
}
三、程序编写题
#include <stdio.h>
void fun (int *a, int *n)
{
}
main( )
{ int aa[1000], n, k ;
void NONO ( );
fun ( aa, &n ) ;
for ( k = 0 ; k < n ; k++ )
if((k + 1) % 10 == 0) printf("\n") ;
else printf("%5d", aa[k]) ;
NONO( );
}
void NONO ( )
{/* 本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/
int aa[1000], n, k ;
FILE *fp ;
fp = fopen("K:\\k01\\24010001\\out.dat","w") ;
fun ( aa, &n ) ;
for ( k = 0 ; k < n ; k++ )
if((k + 1) % 10 == 0) fprintf(fp, "\n") ;
else fprintf(fp, "%5d", aa[k]) ;
fclose(fp) ;
}