【计算机类职业资格】二级C语言笔试300及答案解析.doc
《【计算机类职业资格】二级C语言笔试300及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】二级C语言笔试300及答案解析.doc(20页珍藏版)》请在麦多课文档分享上搜索。
1、二级 C 语言笔试 300 及答案解析(总分:100.00,做题时间:90 分钟)一、B选择题/B(总题数:50,分数:60.00)1.有以下程序: #include stdio.h main() FILE *fp;int i,k=0,n=0; fp=fopen(“d1.dat“,“w“); for(i=1;i4;i+) fprintf(fp,“%d“,i); fclose(fp); fp=fopen(“d1.dat“,“r“); fscanf(fp,“%d%d“,printf(“%d%d/n“,k,n); fclose(fp); 执行后的输出结果是( )。(分数:1.00)A.1 2B.12
2、3 0C.1 23D.0 02.以下四个选项,不能看作一条语句的是( )。(分数:1.00)A.;B.a=0,b=0,c=0;C.if(a0);D.if(b= =0) m=1;n=2;3.设有以下定义: int a=0; double b=1.25; char c=A; #define d 2 则下面语句中错误的是( )。(分数:1.00)A.a+;B.b+;C.c+;D.d+;4.以下符合 C 语言语法的实型常量是( )。(分数:1.00)A.1.2E0.5B.3.14159EC5E-3D.E155.下列有关数据库的描述,正确的是( )。(分数:1.00)A.数据库是一个 DBF 文件B.数
3、据库是一个关系C.数据库是一个结构化的数据集合D.数据库是一组文件6.设有定义:float a=2,b=4,h=3;以下 C 语言表达式中与代数式 (分数:1.00)A.(a+ *h/2B.(1/2)*(a+*hC.(a+*h*1/2D.h/2*(a+7.有以下程序段: int a10=1,2,3,4,5,6,7,8,9,10,*p= b=p5;则 b 中的值是( )。(分数:1.00)A.5B.6C.8D.98.以下程序段中与语句 k=ab? (bc? 1:0):0;功能等价的是( )。(分数:1.00)A.if(a else k=0;B.if(a|(b) k=1; else k=0;C.i
4、f(a= k=0; else if(b= k=1;D.if(a k=1; else if(b k=1; else k=0;9.下列说法中,不属于数据模型所描述的内容的是( )。(分数:1.00)A.数据结构B.数据操作C.数据查询D.数据约束10.有以下程序: #include sldio.h main() int x=0,y=5,z=3; while(z-0 printf(“%d,%d,%d/n“,x,y,z); 程序执行后的输出结果是( )。(分数:1.00)A.3,2,0B.3,2,-1C.4,3,-1D.5,-2,-511.下面不属于软件设计原则的是( )。(分数:1.00)A.抽象B
5、.模块化C.自底向上D.信息隐蔽12.有以下程序: #include stdio.h void swap1(int c) int t; t=c0; c0=c1; c1=t; void swap2(int c0,int c1) int t; t=c0; c0=c1; c1=t; main() int a2=3,5,b2=3,5; swap1(a); swap2(b0,b1); printf(“%d%d%d%d/n“,a0,a1,b0,b1); 其输出结果是( )。(分数:1.00)A.5 3 5 3B.5 3 3 5C.3 5 3 5D.3 5 5 313.有以下程序: #include std
6、io.h main() int i,s=0; for(i=1;i10;i+ =2) s+ =i+1; printf(“%d/n“,s); 程序执行后的输出结果是( )。(分数:1.00)A.正整数 19 的累加和B.正整数 110 的累加和C.正整数 19 中奇数之和D.正整数 110 中偶数之和14.有以下程序: #include stdio.h int f(int b 4) int i,j,s=0; for(j=0;j4;j+) i=j; if(i2) i=3-j; s+=bij; return s; main() int a44=1,2,3,4,0,2,4,6,3,6,9,12,3,2,
7、1,0; printf(“%d/n“,f(a); 执行后的输出结果是( )。(分数:1.00)A.12B.11C.18D.1615.有以下程序: #include stdio.h main() unsigned char a,b; a=413; b=4 printf(“%d%d/n“,a,b); 执行后的输出结果是( )。(分数:1.00)A.7 0B.0 7C.1 1D.43 016.以下数据结构中不属于线性数据结构的是( )。(分数:1.00)A.队列B.线性表C.二叉树D.栈17.有以下程序(提示:程序中 fseek(fp,-2L*sizeof(int),SEEK_END);语句的作用是
8、使位置指针从文件末尾向前移 2 * sizeof(int)字节): #include stdio.h main() FILE *fp; int i, a4=1,2,3,4,b; fp=fopen(“data.dar“,“wb“); for(i=0;i4;i+) fwrite( fclose(fp); fp=fopen(“data.dar“,“rb“); fseek(fp,-2L*sizeof(int),SEEK_END); fread( /*从文件中读取 sizeof(int)字节的数据到变量 b 中*/ fclose(fp); printf(“%d/n“,b); 执行后的输出结果( )。(分
9、数:1.00)A.2B.1C.4D.318.有以下程序: #include stdio.h main() char a=“abcdefg“,b10=“abcdefg“; printf(“%d%d/n“,sizeof(a),sizeof(b); 执行后的输出结果是( )。(分数:1.00)A.7 7B.8 8C.8 10D.10 1019.在结构化方法中,用数据流图(DFD)作为描述工具的软件开发阶段是( )。(分数:1.00)A.可行性分析B.需求分析C.详细设计D.程序编码20.有以下定义: #include stdio.h char a10, *b=a; 下面不能给数组 a 输入字符串的语
10、句是( )。(分数:1.00)A.gets(B.gets(a0);C.gets(D.gets(;21.有以下程序: #include stdio.h void sort(int a,int n) int i,j,t; for(i=0;in-1;i+=2) for(j=i+2;jn;j+=2) if(aiaj)t=ai;ai=aj;aj=t; main() int aa10=1,2,3,4,5,6,7,8,9,10,i; sort(aa,10); for(i=0;i10;i+) printf(“%d.“,aai); printf(“/n“); 其输出结果是( )。(分数:1.00)A.1,2,3
11、,4,5,6,7,8,9,10,B.10,9,8,7,6,5,4,3,2,1,C.9,2,7,4,5,6,3,8,1,10,D.1,10,3,8,5,6,7,4,9,2,22.有以下程序: #include stdio.h #include string.h main(int argc,char *argv) int i,len=0; for(i=1;iargc;i+=2)len+=strlen(argvi); prinff(“%d/n“,len); 此程序经编译链接后生成的可执行文件是 ex.exe,若运行时输入以下带参数的命令行: ex abed efg h3 k44 则执行后的输出结果时
12、( )。(分数:1.00)A.14B.12C.8D.623.有以下程序: #include stdio.h main() char k; int i; for(i=1;i3;i+) scanf(“%c“, switch(k) case 0: printf(“another/n“); case 1: printf(“number/n“); 程序运行时,从键盘输入:01回车,程序执行后的输出结果是( )。(分数:1.00)A.another numberB.another number anotherC.another numberD.number number24.若程序中定义了以下函数: do
13、uble myadd(double a,double b) return(a+b);并将其放在调用语句之后,则在调用之前应该对函数进行说明,以下选项中错误的说明是( )。(分数:1.00)A.double myadd(double a,;B.double myadd(double,doubl;C.double myadd(double b, double ;D.double myadd(double x, double ;25.若以下选项中的变量已正确定义,则正确的赋值语句是( )。(分数:1.00)A.x1=26.8%3;B.1+2=x2;C.x3=0x12;D.x4=1+2=3;26.有以
14、下程序: #include stdio.h main() int x=102,y=012; printf(“%2d,%2d/n“,x,y); 执行后的输出结果是( )。(分数:1.00)A.10,01B.02,12C.102,10D.02,1027.结构化程序设计主要强调的是( )。(分数:1.00)A.程序的规模B.程序的易读性C.程序的执行效率D.程序的可移植性28.以下叙述中正确的是( )。(分数:1.00)A.C 语言的源程序不必通过编译就可以直接运行B.C 语言中的每条可执行语句最终都将被转换成二进制的机器指令C.C 语言程序经编译形成的二进制代码可以直接运行D.C 语言中的函数不可
15、以单独进行编译29.有以下程序: #include stdio.h void f(int v, int w) int t; t=v; v=w; w=t; main() int x=1,y=3,z=2; if(xy) f(x,y); else if(yz) f(y,z); else f(x,z); printf(“%d,%d,%d/n“,x,y,z); 执行后的输出结果( )。(分数:1.00)A.1,2,3B.3,1,2C.1,3,2D.2,3,130.以下程序段中,不能正确赋字符串(编译时系统会提示错误)的是( )。(分数:1.00)A.char s10=“abcdefg“;B.char t
16、=“abcdefg“,*s=t;C.char s10;s=“abcdefg“;D.char s10;strcpy(s,“abcdefg“);31.有以下程序: #include stdio.h int a=2; int f(int *a) return (*a) +; main() int s=0; int a=5; s+=f( s+=f( printf(“%d/n“,s) 执行后的输出结果是( )。(分数:1.00)A.10B.9C.7D.832.有以下程序: #include stdio.h void f(int a,int i, int j) int t; if(ij) t=ai;ai=
17、aj;aj=t; f(a,i+1,j-1); main() int i,aa5=1,2,3,4,5; f(aa,0,4); for(i=0;i5;i+) printf(“%d,“,aai);printf(“/n“); 执行后的输出结果是( )。(分数:1.00)A.5,4,3,2,1,B.5,2,3,4,1,C.1,2,3,4,5,D.1,5,4,3,2,33.设有定义:int n=0,*p=则以下选项中,正确的赋值语句是( )。(分数:1.00)A.P=1B.*q=2;C.q=p;D.*p=5;34.下列关于栈的叙述中正确的是( )。(分数:1.00)A.在栈中只能插入数据B.在栈中只能删除
18、数据C.栈是先进先出的线性表D.栈是先进后出的线性表35.有以下程序: #include stdio.h main() int i,n=0; for(i=2;i5;i+) do if(i%3) continue; n+; while(! i); n+; printf(“n=%d/n“,n); 程序执行后的输出结果是( )。(分数:1.00)A.n=5B.n=2C.n=3D.n=436.有以下程序: #include stdio.h struct STU char name10; int num; int Score; ; main() struct STU s5=“YangSan“,20041
19、,703,“LiSiGuo“,20042,580, “WangYin“,20043,680,“SunDan“,20044,550, “Penghua“,20045,537, *p5,*t; int i,j; for(i=0;i5;i+) pi= for(i=0;i4;i+) for(j=i+1;j5;j+) if(pi-Scorepj-Score) t=pi;pi=pj;pj=t; printf(“%d%d/n“,s1.Score,p1-Score); 执行后的输出结果是( )。(分数:1.00)A.550 550B.680 680C.580 550D.580 68037.有以下程序: #in
20、clude stdio.h #include string.h main() char *p10=“abc“,“aabdfg“,“dcdbe“,“abbd“,“cd“; printf(“%d/n“,strlen(p4); 执行后的输出结果是( )。(分数:1.00)A.2B.3C.4D.538.有以下程序: #include stdio.h void sum(int *a) a0=a1; main() int aa10=1,2,3,4,5,6,7,8,9,10,i; for(i=2;i=0;i-) sum( printf(“%d/n“,aa0); 执行后的输出结果是( )。(分数:1.00)A
21、.4B.3C.2D.139.有以下程序: #include stdio.h char fun(char x,char y) if(xy) return x; return y; main() int a=9,b=8,c=7; printf(“%c/n“,fun(fun(a,b),fun(b,c); 程序的执行结果是( )。(分数:1.00)A.函数调用出错B.8C.9D.740.对长度为 n 的线性表进行顺序查找,在最坏情况下所需要的比较次数为( )。(分数:1.00)A.n+1B.nC.(n+1)/2D.n/241.有以下程序: #include stdio.h #define f(x) x
22、*x main() int i; i=f(4+4)/f(2+2); priatf(“%d/n“,i); 执行后的输出结果是( )。(分数:2.00)A.28B.22C.16D.442.有以下程序: #include stdio.h struct STU char name10; int num; ; void f1(struct STU c) struct STU b=“LiSiGuo“,2042; c=b; void f2(struct STU *c) struct STU b=“SanDan“,2044; *c=b; main() struct STU a=“YangSan“,2041,
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 二级 语言 笔试 300 答案 解析 DOC
