金陵科技学院校内二级复习题 联系客服

发布时间 : 星期二 文章金陵科技学院校内二级复习题更新完毕开始阅读891d87ebf524ccbff1218456

找到,返回此元素的下标;若未找到,则返回值-1.请填空: binary(int a[10],int m) { int low=0,high=9,mid; while(low<=high) { mid=(low+high)/2;

if(ma[mid]) 【2】 else return(mid); }

return(-1); }

main()

{ int a[]={1,3,5,7,9,11,13,15,17,19},m,r; scanf(\

r=binary(【3】); if(r==-1) printf(\ else printf(\}

=======(答案1)======= high=mid-1:

=======(答案2)======= low=mid+1:

=======(答案3)======= a,m

以下程序的功能是:实现两个复数相加的计算并输出运算结果. #include #include struct comlex { float r,i; };

struct complex *cal(struct complex *x1,struct complex *x2) { struct complex *p;

p=(【1】) malloc(sizeof(struct complex)); p->r=(*x1).r+(*x2).r; p->i=(*x1).i+(*x2).i; 【2】; }

main()

{ struct complex *p,x,y;

scanf(\ p=cal(&x,&y);

printf(\【3】); free(p); }

=======(答案1)=======

struct complex *

=======(答案2)======= return p

=======(答案3)======= p->r,p->i

在调用函数fopen(\时,若A盘根目录下不存在文件b.dat,则函数的返回值是【1】. =======(答案1)======= 0

当程序读写数据文件时,需要有声明语句\*fp;\在该声明语句之前必须包含的头文件名为【1】.

=======(答案1)======= stdio.h

若有声明\执行语句\后 输出结果是【1】.

=======(答案1)======= 0

当运行以下程序时,从键盘输入 control<回车> cat<回车> bed<回车> -1<回车>

则以下程序的运行结果是【1】. #include \main()

{ char s[80],*p; p=s; gets(p);

while(*p!='-')

{ if(*p=='a'||*p=='b') puts(p); gets(p); } }

=======(答案1)======= bed

以下程序运行时输出到屏幕的结果是【1】 。 #include int fun(int *x,int n) { if(n==0) return x[0];

else return x[0]+fun(x+1,n-1); }

void main( )

{ int a[]={1,2,3,4,5,6,7}; printf(\}

=======(答案1)======= 6

C语言中,函数值类型的定义可以缺省,此时函数值的隐含类型是【1】. =======(答案1)======= int

#include

void fun(int *a,int b,int *c) { *a=++b;b=*c;*c=*a; } main()

{ int a=10,b=20,c=30; { int a=4; c=a+b;

printf(\{ int c=b; fun(&a,b,&c); printf(\}

printf(\} }

程序输出的第一行是【1】,第二行是【2】,第三行是【3】. =======(答案1)======= 48

=======(答案2)======= 62

=======(答案3)======= 65

在带头结点的单链表中,编一函数删除数据域值为x的结点. struct link *delete_link(struct link *head,int x) { struct link *q,*m; q=head;

m=head->next;

while((m!='\\0')&&(【1】)) /*寻找被删除结点m*/ { q=m; /*q始终指向m之前的结点*/ m=m->next;

}

if(【2】) /*不存在符合条件的结点*/ printf(\ else /*逻辑删除结点*/ { q->next=m->next; 【3】; }

return(head); }

=======(答案1)======= m->data!=x

=======(答案2)======= m==NULL

=======(答案3)======= free(m)

以下程序运行时输出到屏幕的结果是【1】 。 #include void main() { FILE *fp;

int k,n,a[6]={1,2,3,4,5,6}; fp=fopen(\

fprintf(fp,\ fprintf(fp,\ fclose(fp);

fp=fopen(\ fscanf(fp,\ printf(\ fclose(fp); }

=======(答案1)======= 123,456

设已有非空文本数据文件file1.dat,要求能读出文件中原有的全部数据,并在文件原有数据 之后添加新数据,则用FILE *fp=fopen(\【1】\打开该文件. =======(答案1)======= \

若有声明\执行语句\后输出结果是【1】. =======(答案1)======= 0

下面程序输出结果为【1】. main()