C语言程序设计考研真题(B卷答案)_第1页
C语言程序设计考研真题(B卷答案)_第2页
C语言程序设计考研真题(B卷答案)_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、参考答案 (b) 一、选择题(每题2分,共 20 分)1. a 2. d 3. c 4. b 5. a 6. a 7. b 8. c 9. b 10. d 二、读程序写结果(每题5 分,共 20 分)1. 5, 4, 3 2. c+ java dephi 3. 8*6*4*2*0 8*6*4*2*0 8*6*4*2*0 8*6*4*2*0 8*6*4*2*0 4. 2345 5. 4 25 27 16 三、程序填空题(每空3 分,共 60 分)1. (1)i=i+2 (2) 1 (3)i=1;in-1;i=i+2 (4)1 (5) (flag) 2. (1)(low+high)/2 (2) m

2、id (3)bsearch(a,low,mid-1,k) (4)bsearch(a,mid+1,high,k) (5) -1 3. (1)scanf(%d,&ai) (2) &x (3)ai (4)x+ (5) x10 4.( 1)a (2)qu*t ( 4)q-n=v ( 5)(q+1)-m=s (6)a+b ( 7)sort(n,x) ( 8)yleft (3)t,n,2*i+2 (4)scanf(%d,&n) (5) a,n,0,bitree 四、程序设计题(共50分)1. #include void main() char str100,ch= ; int i,

3、count=0; gets(str); for(i=0;stri;i+) if(ch= &stri!= ) count+; ch=stri; printf(%dn,count); 2.#include void main() int a1000,i,n,k,count,m; scanf(%d%d,&n,&k); for(i=0;in;i+) ai=0; count=0; m=0; i=0; while(countn-1) if(ai=0) m+; if(m=k) ai=1; count+; m=0; i+; if(i=n) i=0; i=0; while(ai) i+;

4、 printf(%dn,i+1); 3. #include struct node int data; int count; void print(struct node a,int n) int i; for(i=0;i=0&ai.datax) ai+1=ai; i-; ai+1=t; int search(struct node a,int n,int x) int i; for(i=0;i=num1) /no insert t=anum1; anum1=ak; ak=t; insert_sort(a,num1); num1+; print(a,num1); 4. #include

5、 #include struct treenode int data; struct treenode *left,*right; void tree(struct treenode *p,int x) if(*p=null) *p=(struct treenode *)malloc(sizeof(struct treenode); (*p)-data=x; (*p)-left=(*p)-right=null; else if(xdata) tree(&(*p)-left,x); else tree(&(*p)-right,x); void traverse(struct treenode *p) if(p) traverse(p-left); printf(%4d,p-data); traverse(p-right); void main() int x; struct treeno

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论