C语言程序设计模拟题.doc

上传人:good****022 文档编号:116392838 上传时间:2022-07-05 格式:DOC 页数:21 大小:191KB
返回 下载 相关 举报
C语言程序设计模拟题.doc_第1页
第1页 / 共21页
C语言程序设计模拟题.doc_第2页
第2页 / 共21页
C语言程序设计模拟题.doc_第3页
第3页 / 共21页
点击查看更多>>
资源描述
中国地质大学(北京)继续教育学院 2015年05课程考试C语言程序设计模拟题(补)一、简答题1、简述C语言程序的结构。二、选择题1、 下面程序段的输出结果是【1】。 int a=60;a+=a-=a+a; printf(“%dn”,a);A) 120B) 60C) -120D) -602、 下面正确的字符常量是【2】。A) cB) /C) “w”D) 3、 以下不能用作标识符的是【3】。A) _26B) ScanfC) caseD) Double4、 下面程序段中循环体执行的次数是【4】。int a=10, b=0;do b+=2; a-=2+b; while(a=0);A) 1B) 2C) 3D) 45、 以下关于函数的叙述正确的是【5】。A) 函数中必须要有return语句B) 函数中可以有多个return语句,但只有一个被执行C) return语句中必须有一个表达式D) 函数中定义的变量不能与其它函数中的变量同名6、 满足x为奇数时值为真,x为偶数时值为假的表达式是【6】。A) !(x%2=1)B) x%2=0C) x%2D) !(x%2)7、 以下语句中无法正确赋值的是【7】。A) char b10=H, e, l, l, o, !;B) char b10; b=“Hello!”;C) char b10; strcpy(b, “Hello!”);D) char b10= “Hello!”;8、 若有以下的定义和语句,则值为5的表达式是【8】。int a=1,2,3,4,5,6,7,8,9,10;A) a5B) aa4C) aa3D) aa59、 若有定义:int k=7;float a=2.5,b=4.7;则表达式a+k%3*(int)(a+b)%2/4的值是【9】。A) 2.B) 2.C) 3.D) 0.10、 已知ch是字符型变量,下面正确的赋值语句是【10】。A) ch=”B) ch=123C) ch=xffD) ch=0811、 下面程序的运行结果是:【11】。 void main() char c=a; if(0=cb后,变量a的值为【12】。A) 0B) 1C) 4D) 513、 以下程序的运行结果是【13】。#include void main() int x1=3,x2=1,x3=1;if(x1=x2+x3) printf(“*”);else printf(“#”);A) 存在语法错误B) 无输出结果C) 输出*D) 输出#14、 下面程序段的输出结果是【14】。#include char p110= “abc”, p2=“ABC”, str50= “xyz”;strcpy(str+2, strcat(p1,p2);printf(“%sn”,str);A) xyabcABC B) zabcABCC) yzabcABCD) xyzabcABC15、 设有:int a=1,b=2,c=3,d=4,m=2,n=2;执行(m=ab)&(n=cd)后n的值为【15】。A) 1B) 2C) 3D) 016、若已定义x和y为double类型,则表达式:x=1, y=x+3/2的值是【16】。A) 1B) 2C) 2.0D) 2.517、 以下程序段的输出结果为【17】。int x=1,y=2;void fun1() x=3; y=4; void fun2(int x,int y) printf(“%d,%dn”,x,y); void main() fun1(); printf(“%d,%d,”,x,y); fun2(5,6);A) 3,4,5,6B) 1,2,5,6C) 1,2,3,4D) 3,4,1,218、 下面程序执行时,while的循环次数是【18】。int i=0;while(i10) if(i1) continue; if(i=5) break; i+;A) 1B) 10C) 6D) 死循环,不能确定次数19、 对一维数组a的说明语句中正确的是【19】。A) int a(10)B) int n=10;an;C) #define SIZE 10int aSIZE;D) int n;scanf(“%d”,&n);int an;20、 若调用一个函数,且此函数中没有return语句,则该函数【20】。A) 没有返回值B) 返回若干个系统默认值C) 能返回一个用户所希望的函数值D) 返回一个不确定的值21、下列运算符中优先级最高的是【21】。 A)! B)% C)= D)&22、若int j=10;执行下列程序后,变量j的正确结果是【22】。switch(j) case 9: j+=1; case 10: j+=1; case 11: j+=1; default: j+=1;A) 10 B) 11 C) 12 D) 1323、下列程序的运行结果是【23】。int ii,x33=1,2,3,4,5,6,7,8,9;for(ii=0;ii2!1 D) a2026、设有程序段 int k=10;while (k=0) k=k-1;则下面描述中正确的是:【26】A)while循环执行10次B)循环是无限循环C)循环体语句一次也不执行D)循环体语句执行一次27、判断两个字符串s1和s2相等的正确语句是【27】。 A) if(s1=s2) B) if(s1=s2) C) if(strcpy(s1,s2) D) if(strcmp(s1,s2)=0)28、以下正确的字符常量的定义为【】。A、c B、“cj”C、 abc D、 29、若x、y都是int型变量,且x=100,y=200,则printf(“%d”,(x,y);的输出结果是【】。A) 200B) 100C) 100 200D) 不确定30、运行以下程序,如果从键盘输入ABCDE,则输出结果是【】。#include int funch (char str) int num=0;while( strnum!= 0) num+;return (num);void main( ) char str10;gets(str);printf(“%dn”,funch(str);A) 7B) 6C) 5D) 431、为表示关系x=y=z,下面C语言表达式中正确的是【】。A) (x=y)&(y=z)B) (x=y)and(y=z)C) (x=y=z)D) (x=y)&(y=z)32、下面程序段的输出结果是【】。 int x=2,y=0,z; x*=3+2; printf(“%d ”,x); x*=y=z=4; printf(“%d”,x); A) 8 40B) 10 40C) 10 4D) 8 433、下列程序段的输出结果为【】。int a=9;a+=a-=a+a;printf(“%dn”,a);A) 18B)9C) -18D) -934、设有整型变量a的值为5,使整型变量b的值不为2的表达式【】。A) b=a/5B)b=6-(-a)C) b=a%2D) b=(a-a-,a/2)35、语句printf(“abrehiyboun”)的输出结果为【】。A) abrehiybouB)abrehiybouC) rehiyouD) abrehiybou36、设a,b,c,d均是int型变量,为了使以下程序输出为:1234+123+12+1,正确的输入形式应当为【】。 scanf(“%4d+%3d+%2d+%1d”,&a,&b,&c,&d);printf(“%4d+%3d+%2d+%1d”,a,b,c,d);A) B)41234C) 1234+1234+1234+1234D) 1234+123+12+137、以下程序的输出结果是【】。 void main() int a=1,b=1; switch (a+b) case 2 : printf(*n); case 3 : printf(*n); A) *B)*C) *D) * *38、分析以下程序,以下程序【】。 void main() int x=5,a=0,b=0; if(x=a+b) printf(“*n”); else printf(“#n”); A) 有语法错,不能通过编译B)通过编译,但不能连接C) 输出*D) 输出#39、假定所有变量均已正确说明,下列程序段运行后x的值是【】。a=b=c=0;x=35; if(! a) x=-1; else if(b); if(c) x=3; else x=4;A) -1B)4C) 35D) 340、下面程序运行的结果是【】。#include void main() int i,j,x=0;for(i=0;i2;i+)x+; for(j=0;j=3;j+) if(j%2) continue;x+; x+;printf(“x=%dn”,x);A) x=4B)x=8C) x=6D) x=1241、下面程序的运行结果是【】。#include “stdio.h”void main()int i,j,a=0;for(i=0;i2;i+) for(j=0;j=0&chi=9;i+=2) s=10*s+chi-0;printf(“%dn”,s);A) 1B)1256C) 12ab56D) 743、下面程序的运行结果是【】。void main()char a=“morning”,t;int i,j=0;for(i=1;i7;i+) if(ajai)j=i; t=aj; aj=a7; a7=aj; puts(a);A) mogninrB)moC) morningD) mornin44、以下正确的函数说明形式是【】。A) double fun(int x,int y)B)double fun(int x;int y)C) double fun(int x,int y);D) double fun(int x,y);45、以下程序的输出结果是【】。void fun(int a, int b, int c)a=456; b=567; c=678;void main()int x=10, y=20, z=30;fun (x, y, z);printf(%d,%d,%d, x, y, z);A) 30,20,10B)10,20,30C) 456,567,678D) 678,567,456三、程序选择题1、 下面程序是从键盘中输入学号,然后输出学号中百位数字为3的学号,输入0时结束循环,请选择填空。#include void main() long int num;scanf(“%ld”,&num);doif(【1】) printf(“%ld”,num); scanf(“%ld”,&num);while(【2】);【1】A)num%100/10=3B) num/10%10=3C)num%10/10=3D) num/100%10=3【2】A)!numB) !num=0C)num0=0D) !num!=02、 下面程序段的运行结果是【3】。(其中表示空格)char c5=a,b,0,c,0;printf(“%s”,c);【3】A)a bB) abC)abcD) abc3、下列程序的运行结果是【4】。 int i, x33=1,2,3,4,5,6,7,8,9; for(i=0;i3;i+) printf(“%d”,xi2-i);【4】A)1,5,9B) 1,4,7C)3,5,7D) 3,6,94.下面的程序将字符串s中的每个字符按升序插入到数组a中,请选择填空。#include #include void main() char a20= “cehiknqtw”; char s=“bafl”;int i,j,k;for(k=0; 【5】;k+) j=0; while(sk=aj&aj!= 0) j+; for(【6】) ai+1=ai; aj=【7】;puts(a);【5】A)sk!= 0B) sk!= 0C)sk=0D) sk!=0【6】A)i=strlen(a)+k;i=j;i-B) i=strlen(a); i=j;i-C)i=j; i=strlen(a)+k; i+D) i=j; i=strlen(a); i+【7】A)akB) sk+1C)skD) sk-15.下面程序的功能是找出数组中的最大值和此元素的下标,请选择填空。#include void main() int a10=4,6,8,2,0,9,23,5,67,1,k,p;【8】;for(k=1;kap)【9】;printf(”最大值=%d, 下标=%dn”,ap,【10】);【8】A)p=a0B)p=0C)p=1D) p=a(0)【9】A)p=kB) ap=akC)ak=apD) k=p【10】A)kB) pC)akD) ap四、填空题1、 以下程序求解百钱百鸡问题,公鸡五元一只,母鸡三元一只,小鸡一元三只,用一百元买一百只鸡,且必须有公鸡、母鸡和小鸡,求解所有可能的方案。请填空。#include void main()【1】; n=0;for(i=1;i=18; 【2】) for(j=1;j=31;j+) k=【3】; if(【4】=300) n+; printf(“n=%d,cock=%d,hen=%d,chick=%dn”,n,i,j,k);2、以下程序段的输出结果是 【5】。int k, j, s;for(k=2;k6;k+,k+) s=1; for(j=k;j6;j+) s+=j;printf(“%dn”,s);3.输入一个整数10,以下程序的运行结果是【6】。#includemain() int a, e10, c, i=0; printf(“输入一个整数n”); scanf(“%d”, &a); while(a!=0) c=sub(a); a=a/2; ei=c; i+;for(;i0;i-)printf(“%d”, ei-1);sub(int a) int c; c=a%2; return c;4、下面的函数invert的功能是将一个字符串的内容颠倒过来. void invert(char str) int i, j, 【7】; for(i=0,j=strlen(str); 【8】;i+,j-) k=stri;stri=strj;strj=k; 5、在C语言中,要求对所有用到的变量,遵循先定义后【9】的原则。6、C语言规定,可执行程序的开始执行点是【10】。7. 设float x=2.5,y=4.7; int a=7;,则表达式 x+a%3*(int)(x+y)%2/4 的值为【11】。8. 判断变量a、b的值均不为0的逻辑表达式为【12】。9. 整型变量m的值为27,语句 printf(m=%x,m);的输出结果为【13】。10. 如定义语句为char a=windows ,b=95;,语句printf(%s,strcat(a,b);的输出结果为【14】。11int i=234,j=567; 函数printf(%d%dn,i,j) 的输出结果是【15】。12. 求1至100的和,程序应写成for(s=0,i=1;【16】;+i) s+=i;13. 定义a为长度为10的字符串,同时为字符串赋初值continue的语句为【17】。14. 已知方程ax2+bx+c=0系数a、b、c且存在两个实根,计算其中一个实根的算术表达式为【18】。15. 若 s=d,执行语句 s=(s=a&s=z)?s-32:s; 字符变量s的值为【19】。16. 函数change定义如下,若a=10、b=5,执行 change(a,b)后a、b的值分别为【20】。 void change(int a,int b) int t=0; t=a; a=b; b=t;四、阅读程序题1、以下程序的输出结果是 。 #include int fun(int n) int r;if(n=1|n=2) r=1;elser=fun(n-1)+fun(n-2); return r;void main() printf(%dn,fun(8); 五、 编程题1.输入10个数据,用选择法对10个数由小到大排序,并输出。2.写一个函数,用于求n个学生的平均成绩:并设计主函数,定义一个一维数组score里面存放10个学生的成绩,输出这10位学生的平均成绩。3.有一个3*4的矩阵,要求编写程序求出其中值最大的那个元素的值,以及所在的行号和列号。4.写一个函数,求10个学生的平均成绩:并设计主函数,定义一个一维数组score里面存放10个学生的成绩,输出这10位学生的平均成绩。5.求Fibonacci数列的前40个数。1,1,2,3,5,8,13。参考答案:一、简答题1、1)一个程序由一个或多个源程序文件组成。 预处理指令、全局声明、函数定义。 2)函数是C程序的主要组成部分。 3)一个函数包括两个部分: 函数首部和函数体(声明部分和执行部分)。 4)程序总是从main函数开始执行的。 5)程序中对计算机的操作是由函数中的C语句完成的。 6)在每个数据声明和语句的最后必须有一个分号。 7)C语言本身不提供输入输出语句。 8)程序应当包含注释。二、选择题(本大题共35小题,每小题1分,共35分)。对每一个【 】,从A)、B)、C)、D)四个供选择的答案中,选出一个正确的答案。12345678910CACCBCBCBC11121314151617181920DACABCADCD21222324252627282930ADCDCCDAAC31323334353637383940ABCCCDADBB4142434445AABCB三、程序选择题12345678910DBCCDBCBAB四、填空题1int i,j,k,n2i+3100-i-j43*5*i+3*3*j+k510610107k8ij9使用10main()函数112.512a!=0&b!=013m=1b14windows 951516i=10017char a10=continue;18(-b+sqrt(b*b-4*a*c)/2/a19D20a=10,b=5四、阅读程序题1、21五、编程题1. #includeint main()void sort(int array,int n);int a10,i;printf(enter array:n);for(i=0;i10;i+)scanf(%d,&ai);sort(a,10);/调用Sort函数,a为数组名,大小为10printf(The sorted array:n);for(i=0;i10;i+)printf(%d ,ai);printf(n);return 0;void sort(int array,int n)int i,j,k,t;for(i=0;in-1;i+)k=i;for(j=i+1;jn;j+)if(arrayjarrayk)k=j;t=arrayk;arrayk=arrayi;arrayi=t;2.方法一:#includeint main()float average(float array10);/函数声明float score10,aver;int i;printf(input 10 score:n);for(i=0;i10;i+)scanf(%f,&scorei);printf(n);aver=average(score); /调用average函数printf(average score is %5.2fn,aver);return 0;float average(float array10)/定义average函数int i;float aver,sum=array0;for(i=1;i10;i+)sum=sum+arrayi;/累加学生成绩aver=sum/10;return(aver);方法二:#includeint main()float average(float array,int n);float score10=67.5,89.5,99,69.5,77,89.5,76.5,54,60,99.5; /定义长度为10的数组printf(The average of class B is %6.2fn,average(score,10); /用数组名score和10作实参return 0;float average(float array,int n) /定义average函数,未指定形参数组长度int i;float aver,sum=array0;for(i=1;in;i+)sum=sum+arrayi; /累加n个学生成绩aver=sum/n;return(aver);3. 题#includeint main()int i,j,row=0,colum=0,max;int a34=1,2,3,4,9,8,7,6,-10,10,-5,2;/定义数组并赋初值max=a00;/先认为a00最大for(i=0;i=2;i+)for(j=0;jmax)/如果某元素大于max,就取代max的原值max=aij;row=i;/记下此元素的行号colum=j;/记下此元素的列好printf(max=%dnrow=%dncolum=%dn,max,row,colum);return 0;4. 题方法一:#includeint main()float average(float array10);/函数声明float score10,aver;int i;printf(input 10 score:n);for(i=0;i10;i+)scanf(%f,&scorei);printf(n);aver=average(score); /调用average函数printf(average score is %5.2fn,aver);return 0;float average(float array10)/定义average函数int i;float aver,sum=array0;for(i=1;i10;i+)sum=sum+arrayi;/累加学生成绩aver=sum/10;return(aver);方法二:#includeint main()float average(float array,int n);float score10=67.5,89.5,99,69.5,77,89.5,76.5,54,60,99.5; /定义长度为10的数组printf(The average of class B is %6.2fn,average(score,10); /用数组名score和10作实参return 0;float average(float array,int n) /定义average函数,未指定形参数组长度int i;float aver,sum=array0;for(i=1;in;i+)sum=sum+arrayi; /累加n个学生成绩aver=sum/n;return(aver);5.题#includeint main()int f1=1,f2=1,f3;int i;printf(%12dn%12dn,f1,f2);for(i=1;i=38;i+)f3=f1+f2;printf(%12dn,f3);f1=f2;f2=f3;return 0;技术官员村位于位于亚运城东部,主干道二以东石楼涌以西的地块,占地面积、m2,总建筑面积、m2,共包括地下室南区、地下室北区、地上部分1栋12栋、服务中心、室外工程等多个单体工程。其中住宅面积m2,共12栋,17栋建筑层数为11层,812栋11层(局部复式顶层),首层局部架空,布置公建配套设施。integrated energy, chemicals and textile Yibin city, are the three core pillars of the industry. In 2014, the wuliangye brand value to 73.58 billion yuan, the citys liquor industry slip to stabilise. Promoting deep development of integrated energy, advanced equipment manufacturing industry, changning district, shale gas production capacity reached 277 million cubic metres, built the countrys first independent high-yield wells and pipelines in the first section, the lead in factory production and supply to the population. 2.1-3 GDP growth figure 2.1-4 Yibin, Yibin city, Yibin city, fiscal revenue growth 2.1.4 topography terrain overall is Southwest, North-Eastern State. Low mountains and hills in the city landscape as the main ridge-and-Valley, pingba small fragmented nature picture for water and the second land of the seven hills. 236 meters to 2000 meters above sea level in the city, low mountain, 46.6% hills 45.3%, pingba only 8.1%. 2.1.5 development of Yibin landscapes and distinctive feature in the center of the city, with limitations, and spatial structure of typical zonal group, 2012-cities in building with an area of about 76.2km2. From city-building situation, old town-the South Bank Center construction is lagging behind, disintegration of the old city is slow, optimization and upgrading, quality public service resources are still heavily concentrated in the old town together. Southbank Centre has not been formed, functions of the service area space is missing. Meanwhile, peripheral group centres service was weak and inadequate accounting for city development, suspicious pattern could not be formed. As regards transport, with the outward expansion of cities, cities have been expanding, centripetal city traffic organization has not changed, integrated energy, chemicals and textile Yibin city, are the three core pillars of the industry. In 2014, the wuliangye brand value to 73.58 billion yuan, the citys liquor industry slip to stabilise. Promoting deep development of integrated energy, advanced equipment manufacturing industry, changning district, shale gas production capacity reached 277 million cubic metres, built the countrys first independent high-yield wells and pipelines in the first section, the lead in factory production and supply to the population. 2.1-3 GDP growth figure 2.1-4 Yibin, Yibin city, Yibin city, fiscal revenue growth 2.1.4 topography terrain overall is Southwest, North-Eastern State. Low mountains and hills in the city landscape as the main ridge-and-Valley, pingba small fragmented nature picture for water and the second land of the seven hills. 236 meters to 2000 meters above sea level in the city, low mountain, 46.6% hills 45.3%, pingba only 8.1%. 2.1.5 development of Yibin landscapes and distinctive feature in the center of the city, with limitations, and spatial structure of typical zonal group, 2012-cities in building with an area of about 76.2km2. From city-building situation, old town-the South Bank Center construction is lagging behind, disintegration of the old city is slow, optimization and upgrading, quality public service resources are still heavily concentrated in the old town together. Southbank Centre has not been formed, functions of the service area space is missing. Meanwhile, peripheral group centres service was weak and inadequate accounting for city development, suspicious pattern could not be formed. As regards transport, with the outward expansion of cities, cities have been expanding, centripetal city traffic organization has not changed, 第21页(共21页)
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 压缩资料 > 医学试题


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!