C语言程序设计第一学期试卷A_第1页
C语言程序设计第一学期试卷A_第2页
C语言程序设计第一学期试卷A_第3页
C语言程序设计第一学期试卷A_第4页
C语言程序设计第一学期试卷A_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

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

文档简介

1、装订线.学院: 年级: 姓名: 学号: .密.封线.中国矿业大学(北京)C语言与程序设计试卷( A 卷) 得分:_ 题号一二三四得分阅卷人一、选择题(1-10每题1分,11-30每题1.5分,共30分)1. 下列选项中,可以作为用户标识符的是CA) int B) 8_cat C) _a_0 D) a+b2. 以下定义语句,有错误的是:C A) char a=x; B) char a=0; C) char a=mn; D) char a=9;3. 设有定义:int x=2; 以下表达式中值不为6的是:DA) x *= x+1 B) x+, 2*x C) x *= (1+x) D) 2*x, x

2、+= 24. 有以下定义:int  a; long  b; double  x, y; 则以下选项中正确的表达式是:BA) a%(x-y)B) a = x!=yC) (a*y)%bD) y = x+y = x5. 以下选项中能表示一个合法常量的是:AA) 整数:1,200B) 实数:-3.5e2.0C) 字符斜杠:''D) 字符串:"007"6. 以下是while语句的一般形式Dwhile(表达式) 语句其中关于“表达式”的说明正确的是:A) 必须是逻辑表达式 B) 必须是关系表达式C) 必须是逻辑表达式或关系表达式 D) 可以

3、是任意合法的表达式7. 若用数组名作为函数调用的实参,则传递给形参的是:A) 数组的首地址) 数组的第一个元素的值) 数组中全部元素的值) 数组元素的个数8. 在定义二维数组int a23;之后,对a的正确引用是:CA) a24 B) a20 C) a00 D) a0,09. 下列语句中正确的是:AA) char *str; str = “CUMTB”; B) char str20; str = “CUMTB”; C) char *str; str = “CUMTB”; D) char str20; str = “CUMTB”;10. 设有定义 int a10, *p=a; 以下能够代表数组元

4、素a4的是:BA) a+4 B) *(p+4) C) *a+4 D) *p + 411. 有如下程序#include <stdio.h>void main()char c1, c2;c1 = 'a' + '6' - '2'c2 = 'a' + '6' - '3'printf("%c,%dn", c1, c2);已知字母a的ASCII码是97,则程序运行后的输出结果是:AA) e,100 B) d,101 C) e, d D)无确定输出结果12. 表达式a += a -

5、= a = 9的值是:DA) 9 B) -9 C) 18 D) 013. 有以下程序#include<stdio.h>void main() int  a=1, b=0;if(!a) b+;else if(a = = 0)if(a) b += 2;else b+=3; printf("%dn", b);程序运行后的输出结果是: AA) 0B) 1C) 2D) 3装订线.学院: 年级: 姓名: 学号: .密.封线.14. 有以下程序#include <stdio.h>void main() int a=1, b=2;whi

6、le(a<6) b += a; a += 2; b %= 10;printf(”%d,%dn”, a, b);程序运行后的输出结果是: BA) 5,11 B) 7,1C) 7,11D) 6,115. 有以下程序#includestdio.h>void main()char s = ”abcedf"printf(”%s,%cn”, s+2, *s+2); 程序运行后的输出结果是BA) cedf, cedf B) cedf, c C) cedf, 字符c的ASCII码值 D) 出错16. 有以下程序#includestdio.h>void main() int y=50

7、; while(y-); /*循环体为空*/ printf(”y=%dn”, y);程序执行后的输出结果是:BA) y=0B) y= -1C) y=1D)while构成无限循环17. 有以下程序#includestdio.h>#includestring.h>void main() char s10”STRING”;s0=0;s1= '0's2= '0'printf(”%d  %dn”, sizeof(s), strlen(s);程序运行后的输出结果是 DA) 6  1B) 7  0C) 6  3D) 10&#

8、160; 018. 以下程序段完全正确的是 CA) int *p; scanf("%d", &p);B) int *p; scanf(“%d”, p);C) int k, *p=&k; scanf("%d", p);D) int k, *p; *p= &k;scanf(“%d”, p);19. 下列定义数组的语句中,正确的是 BA) int N=10; int aN; B) #define N 10int  aN;      C) int&#

9、160; a010;D) int a;20. 有以下程序#includestdioh>void f(int *p);void main() int a5 = 1, 2, 3, 4, 5, *r=a;f( r );printf(“%dn”, *r);void f(int *p) p=p+3;printf(“%d,”,*p);程序运行后的输出结果是 DA) 1,4B) 4,4C) 3,1D) 4,121. 若有以下语句typedef struct my_type int g; char h; TS;装订线.学院: 年级: 姓名: 学号: .密.封线.以下叙述中正确的是DA) 可用my_typ

10、e定义结构体变量B) 可用TS定义结构体变量C) my_type是struct类型的变量D) TS是struct my_type类型的变量22. 数学上的式子 1x10怎么用C语言的表达式来表示:CA) 1x10 B) 1<=x<=10 C)x>=1 && x<=10 D) 以上都不对23. 有以下程序#include <stdio.h>#define f(x) x*xvoid main()int a=5, s, t;s=f(a+1);t=f(a+1);printf("%d,%dn", s, t);程序运行结果是: DA)

11、 11,11 B) 36,36 C) 36,11 D)11,3624. 有如下程序#include <stdio.h>void main()void func(int *p, int *q);int m = 1, n =2, *r = &m;func(r, &n);printf("%d,%dn", m, n);void func(int *p, int *q)p = p+1;*q = *q + 1;程序运行结果为:A A) 1, 3 B)2,3 C) 1,4 D) 1,225. 有如下程序#include <stdio.h>void

12、main()int i, j;for(i=0; i<3; i+, i+) for(j=1; j<4; j+) printf("*");则程序运行后的输出结果是:BA) * B) * C) * D)*26. 若有定义语句int a, b; double x; 则下列选项中没有错误的是 CA) switch(x%2) B) switch(int)x/2.0) case 0: a+; break; case 0: a+; break; case 1: b+; break; case 1: b+; break; default : a+; b+; default : a

13、+; b+; C) switch(int)x%2) D) switch(int)(x)%2) case 0: a+; break; case 0.0: a+; break; case 1: b+; break; case 1.0: b+; break; default : a+; b+; default : a+; b+; 27. 有以下程序#include<stdio.h>int f(int x);void main() int n=1, y; y=f(f(n);printf(“%dn”, y);int f(int x) return x*2; 程序运行后的输出结果是 CA)1B

14、)2C)4D)828. 有以下程序#include<stdio.h>void f(int x) if(x/3 > 1) f(x/3); printf(“%d ”, x); /*%d后有一空格*/装订线.学院: 年级: 姓名: 学号: .密.封线.void main() f(13);printf(“n”); 程序运行后的输出结果是 DA)1 4 13 B)13 4 1 C)13 4 D)4 1329. 有如下程序,其中k的初始值为八进制数#include <stdio.h>void main() int k=013;k+;printf(“%dn”, k); 则程序运

15、行后的输出结果是:CA) 14 B) 13 C) 12 D) 1130. 有以下程序#include<stdio.h>void main( ) int i, s=0; for(i=1; i<=100; i+=2) s+=i; printf(“%dn”,s);程序执行后的输出结果是 CA)自然数1100的累加和 B)自然数199的累加和C)自然数1100中的奇数之和 D)自然数1100中的偶数之和二、填空题(【1】-【10】每空1分,【11】-【20】每空2分,共30分)1C语言使用变量遵循的原则:_先定义后使用_,程序运行的入口函数是: main()函数 ;2某字符数字cha

16、r str10=”abcde”,则sizeof(str)=_10_,str5=0;3循环while(10) printf(“*”),输出*的个数为:_无穷个_;4. 当a=3,b=4,c=5时,写出下列各式的值。 a&&b的值为_1_, a+b>c&&b=c的值为_0_。5若有定义:int a34=1,2,0,4,6,8,10; 则初始化后a22= 8;6程序int n=A-a;printf(“n=%d”,n);输出的结果是:-32 ;7int a10,*p;p=a;则*(p+2)=a2;8下面程序实现判断某一年是否是闰年,读程序填空 #include &

17、lt;stdio.h>void main() int year; scanf(“%d”,&year); if(year%4=0 && _year%100!=0_)|(year%400=0) printf(“是闰年”); else printf(“不是闰年”);9下面程序实现,读程序并填空#include <stdio.h>void main()int i=1,sum=0;for(;i<100;i+) sum+=i; if(_i=50_) break;printf(“sum=%dn”,sum);10下面函数实现求字符串中不包含空格的字符个数;读程序

18、填空int str_len(char *s)int n=0;while(*s!=0) if(s+!=0) n+;return n;11下面函数是求某字符串的子串如:*str=”I Love C Program!”;substr(str,2,4)=”Love”;读程序填空装订线.学院: 年级: 姓名: 学号: .密.封线.char* substr(char *str,int offset,int len)char sub10;int i;for(i=0;i<10 ;i+) subi=*(str+offset+i);subi=0;return sub;12下面程序实现了求3*4矩阵中的最小值

19、并输出;读程序填空#include “stdio.h”int MinValue(int a4)int i,j,min;min=a00;for(i=0;i<3;i+) for(j=0;j<4;j+) if(aij<min) min=aij;return min;void main()int b34=13,21,7,9,-2,5,82,34,63,48,-10,1;printf(“min value is:%dn”,MinValue(b);13下面程序是统计某门课程中不及格的人数,并输出相应的学号;读程序填空#include <stdio.h>struct stufl

20、oat score;char stu_num10;void main()struct stu s10=80,”0801”,45,”0802”,92,”0803”,;int i,n=0;for(i=0;i<10;i+) if(si.score<60) printf(“不及格学号:%sn”,si.stu_num);n+;printf(“不及格人数共有:%dn”,n);三、读程序,写出运行结果(3*5=15分)1. 有以下程序# include<stdio.h>void fun(int *a, int n) int i, j, k, t; for(i=0; i<n-1;

21、 i+) k=i;for(j=i; j<n; j+)if(aj>ak) k=j;if(k!=i)t=ai; ai=ak; ak=t;void main() int a10=1, 2, 3, 4, 5, 6,7, i;fun(a, 5);for(i=0; i<7; i+)printf(“%d,”, ai);printf(“n”);程序运行后的输出结果是 2. 有以下程序#include<stdio.h>void main() int i, n=0,0,0,0,0; for (i=1; i<5; i+) ni=ni-1*3+1; printf(“%d ”,ni)

22、; /*%d后有一空格*/装订线.学院: 年级: 姓名: 学号: .密.封线. 程序运行后的输出结果是 3. 有以下程序void inverse(int c, int n) int temp, i; for(i=0; i<n/2-1; i+) temp =ci; ci=cn-i-1; cn-i-1= temp; void swap(int x,int y) int temp; temp =x; x=y; y= temp;void main( ) int a10=1,2,3,4,5,6,7,8,9,0, b5=1,2,3,4,5; inverse(a, 2);swap(b0,b1);pri

23、ntf(“%d,%d,%d,%dn”,a0,a1,b0,b1);程序运行结果是 4. 有以下程序 # include <stdio.h> #include <string.h> struct my_type int a; char b10; double c; ;void main() void f(struct my_type t);struct my_type a=100, “Zhangsan”, 99.5; f(a); printf(“%d,%s,%.2fn”, a.a, a.b, a.c); void f(struct my_type t) t.a = 101; strcpy(t.b, “Lisi”); t

温馨提示

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

评论

0/150

提交评论