微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!
第17套题
一、程序填空题
#include <stdio.h>
void fun(char *s, char c)
{ int i, j, n;
/**********found**********/
for(i=0; s[i]!=___1___ ; i++)
if(s[i]==c)
{
/**********found**********/
n=___2___ ;
while(s[i+1+n]!='\0') n++;
for(j=i+n+1; j>i; j--) s[j+1]=s[j];
/**********found**********/
s[j+1]=___3___ ;
i=i+1;
}
}
main()
{ char s[80]="baacda", c;
printf("\nThe string: %s\n",s);
printf("\nInput a character: "); scanf("%c",&c);
fun(s,c);
printf("\nThe result is: %s\n",s);
}
二、程序改错题
#include <stdio.h>
double fun ( int x[])
{
/************found************/
int sum = 0.0;
int c=0, i=0;
while (x[i] != 0)
{ if (x[i] > 0) {
sum += x[i]; c++; }
i++;
}
/************found************/
sum \= c;
return sum;
}
main( )
{ int x[1000]; int i=0;
printf( "\nPlease enter some data (end with 0): " );
do
{ scanf("%d", &x[i]); }
while (x[i++] != 0);
printf("%f\n", fun ( x ));
}
三、程序编写题
#include <stdio.h>
double fun(int n)
{
}
main()
{ int n; double s;
void NONO ( );
printf("\nPlease enter N:"); scanf("%d", &n);
s = fun(n);
printf("the result is: %f\n", s);
NONO();
}
void NONO ( )
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */
FILE *fp, *wf ;
int i, n ;
double 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", &n) ;
s = fun(n) ;
fprintf(wf, "%f\n", s) ;
}
fclose(fp) ;
fclose(wf) ;