填空题下列给定程序中函数fun的功能是:求出如下分数序列的前n项之和,和值通过函数值返回。例如,若n=5,则应输出8.391667。请改正程序中的错误,使其得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!试题程序:#include<stdlib.h>#include<conio.h>#include<stdio.h>/**********found**********/fun(intn){inta=2,b=1,c,k;return(s);}voidmain(){doubles=0.0;for(k=1;k<=n;k++){/*********found*********/s=s+(double)a/b;c=a;a=a+b;b=c;}intn=5;system("CLS");printf("/nThevalueoffunctionis:%f/n",fun(n));}
填空题若有以下定义,则不移动指针p,且通过指针p引用值为98的数组元素的表达式是{{U}} 【9】 {{/U}}。
int w[10]={23,54,10,33,47,98,72,80,61}, *p=w;
填空题耦合和内聚是评价模块独立性的两个主要标准,其中______,反映了模块内部各成分之间的联系。
填空题下列软件系统结构图的宽度为______。
填空题以下函数rotate的功能是:将a所指N行N列的二维数组中的最后一行放到b所指二维数组的第0列中,把a所指二维数组中的第0行放到b所指二维数组的最后一列中,b所指二维数组中其他数据不变。 #define N 4 void rotade (int a[][N],int b[][N]) int i,j; for(i=0;i<N;i++) b[i][N-1]= 【10】 ; 【11】 =a[N-1][i];
填空题以下程序运行后的输出结果是 【6】 。 #include <stdio.h> int a=5; fun (int b) static int a=10; a+ =b++; printf("%d",a); main() int c=20; fun(c); a+ =c++; printf("%d/n",a);
填空题下列给定程序中,函数fun的功能是:将S所指字符串中的所有数字字符移到所有非数字字符之后,并保持数字字符串和非数字字符串原有的次序。
例如,s所指的字符串为“def35adh3kjsdf7”,执行后结果为“defadhkjsdf3537”。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(char *s)
{
int i,j=0,k=0;
char t1[80],t2[80];
for(i=0;s[i]!="/0";i++)
if(s[i]>="0"
______;
}
else
{
t1[k++]=s[i];
}
t2[j]=0;
t1[k]=0;
for(i=0;i<k;i++)
______;
for(i=0;i<______;i++)
s[k+i]=t2[i];
}
main()
{
char s[80]="ba3a54j7sd567sdffs";
pfintf("/nThe original string is:%s/n",s);
fun(s);
pfintf("/nThe result is:%s/n",s);
}
填空题若a=1,b=2,则表达式!(x=a)‖(y=b)&&0的值是______。
填空题数据流图有两种典型的结构形式,它们分别是变换型和 【5】 。
填空题仪由______、选择(分支)和重复(循环)结构构成的程序是结构化程序。
填空题在printf格式字符中,以带符号的十进制形式输出整数的格式字符是{{U}} 【1】 {{/U}};以八进制无符号形式输出整数的格式字符是{{U}} 【2】 {{/U}};以十六进制无符号形式输出整数的格式字符是{{U}} 【3】 {{/U}};以十进制无符号形式输出整数的格式字符是{{U}} 【4】 {{/U}}。
填空题有以下程序:
# include<string.h>
struct STU
{ char name[10];
int num;};
void f(char *name, int num)
{ struct STU s[2]={{"SunDan",20044},{"Penghua",20045}};
num=s[0].num;
strcpy(name,s[0].name);
}
main()
{ struct STU s[2]={{"YangSan",20041},{"LiSiGuo",20042}},*p;
p=f(p->name,p->num);
printf("%s %d/n",p->name,p->num);
}
程序运行后的输出结果是{{U}} 【8】 {{/U}}。
填空题以下程序运行后的输出结果是______。
#include<stdio.h>
main()
{char b[]="ABCDEFG", *chp=
while(--chp>
putchar('/n');
填空题请补充函数proc(),该函数的功能是比较字符串str1和str2的大小,并返回比较的结果。
例如,当str1="abcd",str2="abcc"时,函数proc()返回“>”,比较结果为“str1>str2”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 80
char*proc(char*str1,char*str2)
{
char*p1=str1,*p2=str2;
while(*p1
if(______)
return">";
p1++;
p2++;
}
if("p1==*p2)
return"==";
if(*p1==______)
return"<";
else
return">";
}
void main()
{
char str1[M],str2[M];
system("CLS");
printf("Input str1:/n");
gets(str1);
printf("Input str2:/n");
gets(str2);
printf("/n****the result****/n");
printf("/nstr1%s str2",proc(str1,str2));
}
填空题下面程序段的输出结果是{{U}} 【8】 {{/U}}。
int x=5;
do{printf("%d ",x-=4);
} while (!(--x));
填空题下面pi函数的功能是根据以下公式返回满足精度要求的π的值。请根据以下算法要求补足所缺语句。doublepi(doubleeps)doubles=0.0,t=1.0;intn;for(【18】;t>eps;n++)s+=t;t=n*t/(2*n+1);return(2.0*【19】);
填空题当调用函数时,实参是一个数组名,则向函数传递的是 【9】 。
填空题下面程序的功能是将一个字符串str的内容颠倒过来,请填空。
#include<string.h>
main()
{ inti,j,{{U}} 【8】 {{/U}};char str[]={"1234567"};
for(i=0,j=strlen(str){{U}} 【9】 {{/U}};i<j;i++,j--)
{ k=str[i];str[i]=str[j];str[j]=k;}
printf("%s/n",str);}
填空题下列给定程序中,函数fun的功能是:求k!(k<13),所求阶乘的值作为函数值返回。例如,若k=10,则应输出3628800。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<conio.h>
#include<stdio.h>
long fun(int k)
{
/**********found**********/
if k>1
return(k*fun(k-1));
return 1;
}
main()
{
int k=10;
printf("%d!=%ld/n",k,fun(k));
}
填空题有以下程序: #include<stdio.h> typedef struct int num;double s;)REC; void funl(REC x)x.num=23;x.s=88.5; main() REC a=16,90.0); fun1(a); printf("%d/n",a.num); 程序运行后的输出结果是______。