微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!
第21套题
一、程序填空题
#include
int fun(int x)
{ int n, s1, s2, s3, t;
/**********found**********/
n=__1__;
t=100;
/**********found**********/
while(t<=__2__)
{ s1=t%10; s2=(t/10)%10; s3=t/100;
if(s1+s2+s3==15)
{ printf("%d ",t);
n++;
}
/**********found**********/
__3__;
}
return n;
}
main()
{ int x=-1;
while(x>999||x<0)
{ printf("Please input(0
printf("\nThe result is: %d\n",fun(x));
}
二、程序改错题
#include
#include
void fun (char *s, char *t)
{
/************found************/
int i;
sl = strlen(s);
for (i=0; i
/************found************/
t[i] = s[sl-i];
for (i=0; i
t[sl+i] = s[i];
t[2*sl] = '\0';
}
main()
{ char s[100], t[100];
printf("\nPlease enter string s:"); scanf("%s", s);
fun(s, t);
printf("The result is: %s\n", t);
}
三、程序编写题
#include
void fun(int a, int b, long *c)
{
}
main() /* 主函数 */
{ int a,b; long c;void NONO ();
printf("Input a b:");
scanf("%d%d", &a, &b);
fun(a, b, &c);
printf("The result is: %ld\n", c);
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */
FILE *rf, *wf ;
int i, a,b ; long c ;
rf = fopen("K:\\k01\\24010001\\in.dat","r") ;
wf = fopen("K:\\k01\\24010001\\out.dat","w") ;
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%d,%d", &a, &b) ;
fun(a, b, &c) ;
fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ;
}
fclose(rf) ;
fclose(wf) ;
}