[计算机类试卷]国家二级(C语言)机试模拟试卷129及答案与解析.doc

上传人:twoload295 文档编号:502865 上传时间:2018-11-29 格式:DOC 页数:27 大小:72KB
下载 相关 举报
[计算机类试卷]国家二级(C语言)机试模拟试卷129及答案与解析.doc_第1页
第1页 / 共27页
[计算机类试卷]国家二级(C语言)机试模拟试卷129及答案与解析.doc_第2页
第2页 / 共27页
[计算机类试卷]国家二级(C语言)机试模拟试卷129及答案与解析.doc_第3页
第3页 / 共27页
[计算机类试卷]国家二级(C语言)机试模拟试卷129及答案与解析.doc_第4页
第4页 / 共27页
[计算机类试卷]国家二级(C语言)机试模拟试卷129及答案与解析.doc_第5页
第5页 / 共27页
点击查看更多>>
资源描述

1、国家二级( C语言)机试模拟试卷 129及答案与解析 一、选择题 1 以下关于 C语言数值常量的选项中,合法的是 ( )。 ( A) 12 0Xa23 4 5e0 ( B) 028 5e一 3一 0xf ( C) 177 4e1 5 0abc ( D) 0x8A 10, 000 3 e5 2 若有定义: double d=68; int i=0, k=21;,则以下选项中不符合 C语言规定的赋值语句是 ( )。 ( A) i一 (d+k) =(i+k); ( B) i=d 3; ( C) d=(d+, i+); ( D) i=(int)! d; 3 若有代数式 (其中 e仅代表自然对数的底数,

2、不是变量 ),则以下能够正确表示该代数式的 C语言表达式是 ( )。 ( A) sqrt(fabs(pow(n, x)+exp(x) ( B) sqrt(fabs(pow(n, x)+pow(x, e) ( C) sqrt(abs(n x+e x) ( D) sqrt(fabs(pow(x, n)+exp(x) 4 有关 C语言标识符,以下选项中不合法的是 ( )。 ( A) &a ( B) FOR ( C) print ( D) _00 5 有以下序: #include void main() int num1, num2; int i=10; double d=12 34: nunl=si

3、zeof(i); num2=sizeof(d); pfintf( d, d n, s1, s2); 在 VC 6 0平台上编译运行,程序运行后的输出结果是 ( )。 ( A) 16, 4 ( B) 2, 8 ( C) 4, 8 ( D) 1, 4 6 有以下程序: #nclude void main() char a, b, c, d; scanf( c c, &a, &b); c=getchar(); d=getchar(); pfintf( c c c c n, a, b, c, d); 运行程序后输入数据 (代表回车符 ) 34 56 则输出结果是 ( )。 ( A) 34 ( B) 3

4、456 ( C) 34 ( D) 34 7 以下关于 C语言中逻辑运算符两侧运算对象的叙述中正确的是 ( )。 ( A)只能是整数 0或非 0整数 ( B)可以是任意合法的表达式 ( C)可以是结构体类型的数据 ( D)只能是整数 0或 1 8 有以下程序: #nelude main() int a=0, b=0, C=0, d=0; if(a=1)b=1; c=2; else d=3; pfintf( d, d, d, d n, a, b, c, d); 程序运行后的输出结果是 ( )。 ( A) 1, 1, 2, 0 ( B) 0, 0, 0, 3 ( C)编译有错 ( D) 0, 1,

5、2, 0 9 有以下程序: #include main() int x=1, y=0, a=0, b=0; switch(x) case 1: switch(y) case 0: a+; break; case 1: b+; break; case 2: a+; b+; break; case 3: a+; b+; printf(a= d, b= d n, a, b); 程序运行后的输出结果是 ( )。 ( A) a=2, b=2 ( B) a=2, b=1 ( C) a=1, b=1 ( D) a=1, b=0 10 以下程序段中的变量已正确定义: for(i=0; i 4; i+, i+)

6、 for(k=l; k 3; k+); printf(*); 程序段的输出结果是 ( )。 ( A) * ( B) * ( C) * ( D) * 11 有以下程序段: #nclude int i, n; for(i=0; i 8; i+) n=rand() 5; switch(n) case 1: case 3: printf( d n, n); break; case 2: case 4: printf( d n, n); continue; case 0: exit(0); pfintf( d n, n); 以下关于程序段执行情况的叙述,正确的是 ( )。 ( A) for循环语句固定执

7、行 8次 ( B)当产生的随机数 n为 4时结束循环操作 ( C)当产生的随机数 n为 1和 2时不做任何操作 ( D)当产生的随机数 n为 0时结束程序运行 12 有以下程序: #include int f(int x); main() int n=1, m; m=f(f(f(n); printf( d n, m); int f(int x) retum x*2; 程序运行后的输 出结果是 ( )。 ( A) 8 ( B) 2 ( C) 4 ( D) 1 13 以下叙述中错误的是 ( )。 ( A)可以给指针变量赋一个整数作为地址值 ( B)函数可以返回地址值 ( C)改变函数形参的值,不会

8、改变对应实参的值 ( D)当在程序的开头包含头文件 stdio h时,可以给指针变量赋 NULL 14 设已有定义: float x;,则以下对指针变量 P进行定义且赋初值的语句中正确的是 ( )。 ( A) int*p=(float)x; ( B) float*p=&x; ( C) float p=&x; ( D) float*p=1024; 15 以下数组定义中错误的是 ( )。 ( A) int x 23=1, 2, 3, 4, 5, 6; ( B) int x3=0; ( C) int x3=1, 2, 3, 4, 5, 6; ( D) int x 23=1, 2, 3, 4, 5,

9、6; 16 有以下程序: #include void fun(int a, int n) int i, t; for(i=0; i n 2; i+)t=ai; ai=an一 1一 i; an一 1一 i: t; main() int k10=1, 2, 3, 4, 5, 6, 7, 8, 9, 10, i; fun(k, 5); for(i=2; i 8; i+)printf( d, ki); printf( n); 程序运行后的输出结果是 ( )。 ( A) 321678 ( B) 876543 ( C) 1098765 ( D) 345678 17 有以下程序: #include #def

10、ine N 4 void fun(int aN, int b) int i; for(i=0; i N; i+)bi=aii一 aiN一 1一 i; main() int xNN=1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,16, yN, i; fun(x, y); for(i=0; i N; i+)printf( d, , yi); printf( n); 程序运行后的输出结果是 ( )。 ( A)一 3,一 1, 1, 3 ( B) 12, 3, 0, 0 ( C) 0, 1, 2, 3 ( D)一 3,一 3,一 3,一 3 18

11、设有定义: char s81; int i=0;,以下不能将一行 (不超过 80个字符 )带有空格的字符串正确读入的语句或语句组是 ( )。 ( A) gets(s); ( B) while(si+=getchar()! = n); si= 0; ( C) scanf( s, s); ( D) doscanf( c, &si); while(si+! = n); si= 0; 19 设有定义: char P=1, 2, 3, *q=p;,以下不能计算出一个 char型数据所占字节数的表达式是 ( )。 ( A) sizeof(p) ( B) sizeof(char) ( C) sizeof(*

12、q) ( D) sizeof(p0) 20 有以下程序: #include #include main() char str20=One*World, One*Dream! , *p=str1; printf( d, , strlen(p); printf( s n, p); 程序运行后的输出结果是 ( )。 ( A) 10, One*Dream! ( B) 9, One*Dream! ( C) 9, One*World ( D) 10, One*World 21 有以下程序: #nclude main() char s=012xy 08s34f4w2; int i, n=0; for(i=0

13、; si! =0; i+) if(si =0&si =9)n+; printf( d n, n); 程序运行后的输出结果是 ( )。 ( A) 0 ( B) 3 ( C) 7 ( D) 8 22 有以下程序: #include fun(int x, int y) static int m=0, i=2; i+=m+1; m=i+x+y; return m; main() int j=1, m=1, k; k=fun(j, m); printf( d, , k); k=fun(j, m); printf( d n, k); 程序执行后的输出结果是 ( )。 ( A) 5, 11 ( B) 5,

14、5 ( C) 11, 11 ( D) 11, 5 23 在 C语言中,只有在使用时才占用内存单元的变量,其存储类型是 ( )。 ( A) auto和 static ( B) extem和 register ( C) auto和 register ( D) static和 register 24 下面结构体的定义语句中,错误的是 ( )。 ( A) struct ordint x; int y; int z; struct ord a; ( B) struct ordint x; int y; intz; ; struct ord a; ( C) struct ordint x; int y;

15、int z; a; ( D) structim x; int y; int z; a; 25 有以下程序: #inelude typedef structint b, p; A; void f(A c) *注意: C是结构变量名 * int j; c b+=1: c p+=2; main() int i; A a=1, 2; f(a); printf( d, d n, a b, a p); 程序运行后的输出结果是 ( )。 ( A) 2, 4 ( B) 1, 2 ( C) 1, 4 ( D) 2, 3 26 读取二进制文件的函数调用形式为: fread(buffer, size, count,

16、 fp);,其中buffer代表的是 ( )。 ( A)一个内存块的字节数 ( B)一个整型变量,代表待读取的数据的字节数 ( C)一个文件指针,指向待读取的文件 ( D)一个内存块的首地址,代表读人数据存放的地址 27 有以下程序: #include #include int fun(int n) int*p; p=(int*)malloc(sizeof(int); *P=n; return*p; main() int a; a=fun(10); printf( d n, a+fun(10); 程序运行后的输出结果是 ( )。 ( A) 0 ( B) 10 ( C) 20 ( D)出错 28

17、 有以下程序: #include main() unsigned char a=8, c; c=a 3; printf( d n, c); 程序运行后的输出结果是 ( )。 ( A) 16 ( B) 1 ( C) 32 ( D) 0 29 以下叙述中正确的是 ( )。 ( A)在 C语言中,预处理命令行都以 “#”开头 ( B)预处理命令行必须位于 C源程序的起始位置 ( C) #include必须放在 C程序的开头 ( D) C语言的预处理不能实现宏定义和条件编译的功能 30 下面关于编译预处理的命令行中,正确的是 ( )。 ( A) #define int INT ( B) #define

18、 eps 0 001 ( C) #DEFINE TRUE ( D) #define E 2 88 31 有如下程序 #include main() int i, data; seallf(“ d”, &data) for(i=0; idata&i 3=0)continue; printf(“ d, ”, i); 程序运行时,从键盘输入: 13后,程序输出结果为 ( )。 ( A) 0, 2, 4, ( B) 1, 3, 5, ( C) 0, 1, 2, 3, 4, 5, ( D) 0, 1, 2, 3, 32 设变量 n已正确定义并赋值,以下不能实现自然数 1到 n累加求和的程序段是( )。

19、( A) int sum=1, i=0: while(i void fun(char*s) int i, j=0, k=0; char tl80, t280; for(i=0; si!= 0; i+) if(si=D&si void fun(int n) int j, b, c, m, flag=0; for(b=1; b=c) *found* m=mC; C+ *found* if(m!=0) prinff(“ d=”, n); for(j=b; j #define N 16 typedef struct char hum10; int s; STREC; int fun(STREC* a,

20、 STREC*b) main() STREC sN=“GA05”, 85, “GA03”, 76, “GA02”, 69, “GA04”,85, “GA01”, 91, “GA07”, 72, “GA08”, 64, “GA06”, 87, “GA015”, 85, “GA013”, 91, “GAO12”, 64, “GA014”, 91, “GA011”, 91, “GA017”, 64, “GA018”, 64, “GA016”, 72; STREC hN; int i, n; FILE*out; n=fun(s, h); prinff(“The d lowest score: n”, n); for(i=0; idata始终为假;所以表达式idata&i 3=0始终为假;所以 if语句的判断条件需要看 iai s) min=ai_s; *找出最小值 * for(i=0; iN; i+) if(min=ai s) bj+=ai; *找出成绩与 min相等的学 生的记录,存入结构体 b中 * return j; 【试题解析】 本题考查:查找结构体数组中的最小数据,需要通过 for循环语句和 if条件语句来完成。 本题中第一个循环语句的作用是遍历数组求出最低分数,第二个循环语句的作用是将数组中的元素与最低分比较,查找是否存在与最低分相等的成绩。

展开阅读全文
相关资源
猜你喜欢
  • BS S 148-1969 Specification for low nickel-chromium steel (bar for the manufacture of forged bolts only)《仅用于锻制螺栓的低镍-铬钢棒规范》.pdf BS S 148-1969 Specification for low nickel-chromium steel (bar for the manufacture of forged bolts only)《仅用于锻制螺栓的低镍-铬钢棒规范》.pdf
  • BS S 153-1976 Specification 21 2% nickel-chromium-molybdenum steel billets bars forgings and parts (1230-1430 MPa limiting ruling section 40 mm)《规范 5 2%镍-铬-钼钢方坯、棒材、锻件及零件(1230-1430MPa 限定等圆断面40mm)》.pdf BS S 153-1976 Specification 21 2% nickel-chromium-molybdenum steel billets bars forgings and parts (1230-1430 MPa limiting ruling section 40 mm)《规范 5 2%镍-铬-钼钢方坯、棒材、锻件及零件(1230-1430MPa 限定等圆断面40mm)》.pdf
  • BS S 154-1976 Specification 21 2% nickel-chromium-molybdenum steel billets bars forgings and parts (880-1080 MPa limiting ruling section 150 mm)《规范 5 2%镍-铬-钼钢方坯、棒材、锻件及零件规范(880-1080MPa 限定等圆断面150m.pdf BS S 154-1976 Specification 21 2% nickel-chromium-molybdenum steel billets bars forgings and parts (880-1080 MPa limiting ruling section 150 mm)《规范 5 2%镍-铬-钼钢方坯、棒材、锻件及零件规范(880-1080MPa 限定等圆断面150m.pdf
  • BS S 156-1976 Specification for 4% nickel-chromium-molybdenum case-hardening steel (vacuum arc remelted) billets bars forgings and parts (1320-1520 MPa)《4%镍-铬-钼表面硬化钢(真空电弧重熔)坯、棒材、锻件及零件规范(1320-1520M.pdf BS S 156-1976 Specification for 4% nickel-chromium-molybdenum case-hardening steel (vacuum arc remelted) billets bars forgings and parts (1320-1520 MPa)《4%镍-铬-钼表面硬化钢(真空电弧重熔)坯、棒材、锻件及零件规范(1320-1520M.pdf
  • BS S 157-1976 Specification 3% nickel-chromium-molybdenum case-hardening steel billets bars forgings and parts (1180-1380 MPa)《规范 3%镍-铬-钼表面硬化钢方坯、棒材、锻件及零件(1180-1380MPa)》.pdf BS S 157-1976 Specification 3% nickel-chromium-molybdenum case-hardening steel billets bars forgings and parts (1180-1380 MPa)《规范 3%镍-铬-钼表面硬化钢方坯、棒材、锻件及零件(1180-1380MPa)》.pdf
  • BS S 158-1977 Specification for 1% chromium-molybdenum steel bars for the manufacture of forged bolts and forged nuts《锻制螺栓和螺母的含1%铬-钼钢棒规范》.pdf BS S 158-1977 Specification for 1% chromium-molybdenum steel bars for the manufacture of forged bolts and forged nuts《锻制螺栓和螺母的含1%铬-钼钢棒规范》.pdf
  • BS S 162-1990 Specification for 18% nickel-cobalt-molybdenum maraging steel forging stock forgings bars and parts (1800 MPa double vaccuum melted)《锻坯、锻件、棒材和零件用18%镍-钴-钼马氏体时效钢(1800MPa 双倍真空熔化)规范》.pdf BS S 162-1990 Specification for 18% nickel-cobalt-molybdenum maraging steel forging stock forgings bars and parts (1800 MPa double vaccuum melted)《锻坯、锻件、棒材和零件用18%镍-钴-钼马氏体时效钢(1800MPa 双倍真空熔化)规范》.pdf
  • BS S 163-1990 Specification for nickel-chromium-molybdenum-vanadium steel forging stock forgings bars and parts (1900 MPa limiting ruling section 100 mm)《锻坯 锻件 棒材和零件用镍-铬-钼-钒钢规范(1900MPa 限定控制剖面100mm.pdf BS S 163-1990 Specification for nickel-chromium-molybdenum-vanadium steel forging stock forgings bars and parts (1900 MPa limiting ruling section 100 mm)《锻坯 锻件 棒材和零件用镍-铬-钼-钒钢规范(1900MPa 限定控制剖面100mm.pdf
  • BS S 164-2002 1 % Chromium-molybdenum steel billets bars forgings and parts (1150 to 1300 MPa Limiting ruling section 16 mm) (Suitable for welding)《航空航天系列 1%铬-钼钢坯 棒材 锻件和部件(1150至1300 MPa 限制截面部分为1.pdf BS S 164-2002 1 % Chromium-molybdenum steel billets bars forgings and parts (1150 to 1300 MPa Limiting ruling section 16 mm) (Suitable for welding)《航空航天系列 1%铬-钼钢坯 棒材 锻件和部件(1150至1300 MPa 限制截面部分为1.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1