欢迎来到天天文库
浏览记录
ID:40534263
大小:34.50 KB
页数:6页
时间:2019-08-04
《c语言模拟试题_(16)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、试卷编号:8134所属语言:C语言试卷方案:C语言期末模拟练习试卷总分:100分共有题型:3种一、程序填空共1题(共计30分)第1题(30.0分)题号:470/*-------------------------------------------------------【程序填空】---------------------------------------------------------功能:从两个数组中分别提取任意元素x[i],y[j],问
2、x[i]-y[j]
3、的最小值是多少?------------------------------
4、-------------------------*/#include#include/***********SPACE***********/#definemin(x,y)(【?】)intmin_distance(intx[],inty[],intm,intn){intminimum=INT_MAX;intindex_x=0,index_y=0;while(index_x5、m,x[index_x]-y[index_y]);index_y++;}else{minimum=min(minimum,y[index_y]-x[index_x]);/***********SPACE***********/【?】;}returnminimum;}#includevoidmain(void){intx[]={1,3,7,11,18};intm=sizeof(x)/sizeof(int);inty[]={4,5,8,13,22};intn=sizeof(y)/sizeof(int);inti,min_distan6、ce(int[],int[],int,int);printf("ComputeMinimumDistanceBetweenTwoSortedArrays");printf("==================================================");printf("GivenArray#1:");for(i=0;i7、("MinimumDistance=%d",min_distance(x,y,m,n));}答案:=======(答案1)=======xx?x:y=======(答案2)=======x[index_x]>=y[index_y]=========或=========y[index_y]<=x[index_x]=======(答案3)=======index_x++=========或=========index_x=index_x+1=========或=========++inde8、x_x二、程序改错共1题(共计30分)第1题(30.0分)题号:26/*------------------------------------------------------【程序改错】--------------------------------------------------------功能:实现3行3列矩阵的转置,即行列互换。------------------------------------------------------*/#includefun(inta[3][3],intn){inti,j,t;9、for(i=0;i10、D**********/t=a[j][i];}for(i=0;i
5、m,x[index_x]-y[index_y]);index_y++;}else{minimum=min(minimum,y[index_y]-x[index_x]);/***********SPACE***********/【?】;}returnminimum;}#includevoidmain(void){intx[]={1,3,7,11,18};intm=sizeof(x)/sizeof(int);inty[]={4,5,8,13,22};intn=sizeof(y)/sizeof(int);inti,min_distan
6、ce(int[],int[],int,int);printf("ComputeMinimumDistanceBetweenTwoSortedArrays");printf("==================================================");printf("GivenArray#1:");for(i=0;i7、("MinimumDistance=%d",min_distance(x,y,m,n));}答案:=======(答案1)=======xx?x:y=======(答案2)=======x[index_x]>=y[index_y]=========或=========y[index_y]<=x[index_x]=======(答案3)=======index_x++=========或=========index_x=index_x+1=========或=========++inde8、x_x二、程序改错共1题(共计30分)第1题(30.0分)题号:26/*------------------------------------------------------【程序改错】--------------------------------------------------------功能:实现3行3列矩阵的转置,即行列互换。------------------------------------------------------*/#includefun(inta[3][3],intn){inti,j,t;9、for(i=0;i10、D**********/t=a[j][i];}for(i=0;i
7、("MinimumDistance=%d",min_distance(x,y,m,n));}答案:=======(答案1)=======xx?x:y=======(答案2)=======x[index_x]>=y[index_y]=========或=========y[index_y]<=x[index_x]=======(答案3)=======index_x++=========或=========index_x=index_x+1=========或=========++inde
8、x_x二、程序改错共1题(共计30分)第1题(30.0分)题号:26/*------------------------------------------------------【程序改错】--------------------------------------------------------功能:实现3行3列矩阵的转置,即行列互换。------------------------------------------------------*/#includefun(inta[3][3],intn){inti,j,t;
9、for(i=0;i10、D**********/t=a[j][i];}for(i=0;i
10、D**********/t=a[j][i];}for(i=0;i
此文档下载收益归作者所有