当运行以下程序时,输入 abcd ,程序的输出结果是 : 【 9 】 。
insert(char str[])
{ int i;
i=strlen(str);
while(i>0)
{ str[2*i]=str[i];str[2*i-1]='*'; i--;}
printf(" % s\n",str);
}
main()
{ char str[40];
scanf(" % s",str);insert(str);
}
查看答案
有以下程序
#include <string.h>
main(int argc, char *argv[ ])
{ int i=1,n=0;
while (i< argc) {n=n+strIen (angv[i ] ) ;i++; }
printf("%d\n",n);
}
该程序生成的可执行文件名为: proc.exe 。若运行时输入命令行:
proc 123 45 67
则程序的输出结果是
A. 3
B. 5
C. 7
D. 11
有以下程序
#include <stdio.h>
main()
{ FILE *fp; int i;
char ch[]="abcd",t;
fp=fopen("abc.dat","wb+");
for(i=0; i<4; i++) fwrite(&ch[i],1,1,fp);
fseek(fp,-2L,SEEK_END);
fread(&t,1,1,fp);
fclose(fp);
printf("%c\n",t);
}
程序执行后的输出结果是
A. d
B. c
C. b
D. a
下面程序的运行结果是: 【 17 】 。
#include <stdio.h>
int f(int a[],int n)
{ if(n>1)
return a[0] + f(a+1, n-1);
else
return a[0];
}
main()
{ int aa[10]={1,2,3,4,5,6,7,8,9,10}, s;
s = f(aa+2,4); printf("%d\n", s);
}
以下程序中,函数 fun 的功能是计算 x 2-2x+6 ,主函数中将调用 fun 函数计算:
y1=(x+8) 2-2 (x+8)+6
y2=sin 2(x)-2sin(x)+6
请填空。
#include "math.h"
double fun(double x){ return (x*x-2*x+6); }
main()
{ double x,y1,y2;
printf("Enter x:"); scanf("%lf",&x);
y1=fun(【 11 】 );
y2=fun(【 12 】 );
printf("y1=%lf,y2=%lf\n",y1,y2);
}