logo资料库

2019年四川西南科技大学程序综合设计考研真题.doc

第1页 / 共7页
第2页 / 共7页
第3页 / 共7页
第4页 / 共7页
第5页 / 共7页
第6页 / 共7页
第7页 / 共7页
资料共7页,全文预览结束
2019 年四川西南科技大学程序综合设计考研真题 一、程序阅读与理解。(共计 45 分) 1.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include int main(){ int count=5; while(count<=7){ Count++; printf(“%d\n”,count); } return 0; } 2.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include int main(){ int*p,*q,k=10,j=6; p=&k;q=&j; if(*p<*q) printf(“%d\n”,*p); else printf(“%d\n”,*q); return0;
} 3.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include int main(){ int i; int F[5]={1,1}; for(i=2;i<5;i++) F[i]=F[i-2]+F[i-1]; for(i=0;i<5;i++) printf(“%d”,F[i]); return0; } 4.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include void function(int*x,int*y){ printf(“%d%d”,*x,*y); *x=8;*y=9; } in tmain(){ int x=5,y=6; function(*y,*x); printf(“%d%d”,*x,*y);
return0; } 5.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include int main(){ char string[20]=“Welcome to China!”,*p=string; printf(“%s\n”,p+11); return 0: } 6.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include int main(){ FILE*fp; int i,k=0; fp=fopen(“test.dat”,“w”); for(i=4;i<=8;i++) fprintf(fp,“%d”,i); fclose(fp); fp=fopen(“test.dat”,“r”); fscanf(fp,“%d”,k); printf(“%d\n”,k); fclose(fp);
return0; } 7.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include void function(inta[]){ int i=0; while(a[i]<=10){ printf(“%d”,a[i]); i++; } } int main(){ int D[]={3,6,9,10,4,12,8}; function(D); return 0; } 8.阅读下面程序,请写出程序执行后的输出结果。(5 分) #include int main(){ int k; for(k=1;k<=10;k++){ if(k%3==0)continue;
printf(“%d”,k); } return 0; } 9.阅读下面程序,当输入 3 和 8 时,请写出程序执行后的输出结果。(5 分) #include int main(){ int *pl,*p2,*p,x,y; scanf(“%d%d”,&x,&y); pl=&x;p2=&y; if(x
过程。(16 分) 3.已知有一哈希表长度为 9,哈希函数为 H(K)=K%9(取模运算),给定的关键字集合 {7,8,30,11,18,9,14,26},请计算集合中关键字的哈希地址,并用拉链法构建哈希表。(12 分) 4.霍夫曼编码是一种变长编码方法,请为概率分别为{0.09,0.24,0.26,0.11,0.30}的字 符集合(m,n,h,o,p}构造一棵霍夫曼树,并给出每个符号的编码。(13 分) 5.请详细给出{5,10,20,2,8,7,11,9,14}的冒泡排序过程(升序)。(9 分) 三、算法设计。(共计 45 分) 1.请用 C 语言写出直接选择排序算法的代码,该算法的函数定义如下:(15 分) void selectSort(int R[],int n){ } 2.现有单链表结点类型定义如下: Typedef struct LNode{ ElemType data; struct LNode*next; }HL; 请设计一个算法统计单链表 HL 中结点值等于某个给定值 x 的结点数。(15 分) 3.链式存储的二叉树结点定义如下: Typedef struct Node { ElemType data; struct Node*lchild; struct Node*rchild; }EBTNode;
请写出计算该二叉树高度的算法。(15 分)
分享到:
收藏