[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷9及答案与解析.doc
《[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷9及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷9及答案与解析.doc(22页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C语言(编译预处理和指针)机试模拟试卷 9及答案与解析 一、选择题 1 有以下程序 #include void fun(int*a, int*b) int*c; c=a; a=b; b=c; main() int x=3, y=5, *p=&x, *q=&y; fun(p, q); printf(“ d, d, “, *p, *q); fun(&x, &y); printf(“ d, d n“, *p, *q); 程序运行后的输出结果是 ( A) 3, 5, 5, 3 ( B) 3, 5, 3, 5 ( C) 5, 3, 3, 5 ( D) 5, 3, 5, 3 2 有下列程序: v
2、oid f(int b) int I; for(i=2; i int fun(char s) int n=0 ; while(*s=0) n=10*n+*s-0; s+; return(n); main() char s10=6, 1, *, 4, *, 9, *, 0, *); printf(“ d n“, fun(s); 程序的运行结果是 ( A) 61490 ( B) 61 ( C) 9 ( D) 5 4 若有以下程序 #include void sp(int*a) int b=2; a=&b; *a= *a * 2; printf(“ d, “, *a); ) main()int k=
3、3, *p=&k; sp(p); printf(“ d, d n“, k, *p); ) 则程序的输出结果是 ( A) 4, 3, 4 ( B) 4, 3, 3 ( C) 6, 3, 6 ( D) 6, 6, 6 5 若有以下程序 #include 2nt k=7; void f(int*s) int*t=&k; *s=t; printf(“ d, d, d, “, k, *t, *s); main() inf i=3, *p=&i, *r= &p; f(r); printf(“ d, d, d n“, i, *p, *r); 则程序的输出结果是 ( A) 3, 7, 7, 7, 7, 7 (
4、 B) 7, 7, 7, 3, 3, 3 ( C) 3, 3, 3, 7, 7, 7 ( D) 7, 7, 7, 3, 7, 7 6 若有以下程序 #include int*f(int*s, int*t) int*k; if(*s void sp(int*a) int b=2; *a= *a * 2; printf(“ d, “, *a); a=&b; *a= *a * 2; printf(“ d, “, *a); main() int k=3; sp(&k); printf(“ d n“, k); ) 则程序的输出结果是 ( A) 6, 4, 6 ( B) 6, 4, 3 ( C) 6, 1
5、2, 12 ( D) 9, 4, 9 8 若有以下程序 #include int k=7, m=5; void f(int*s) int*t=&k; S=&t; *s=&m; printf(“ d, d, d, “, k, *t, *s); main() int i=3, *p=&i, *r=&p; f(r); printf(“ d, d, d n“, i, *p, *r) 则程序的输出结果是 ( A) 7, 5, 7, 3, 3, 3, ( B) 7, 5, 7, 3, 5, 7, ( C) 7, 5, 5, 3, 3, 3, ( D) 7, 7, 5, 3, 3, 3, 9 若有以下程序
6、#include int*f(int*s, int*t) int k; if (*s int funa(int a, int b) return a+b; int funb(int a, int b) return a-b; int sss(int: (*t)(), int x, int y) return(*t)(x, y); ) main() int x; x=sss(funa, 9, 3); x+=sss(funb, 8, 3 ); printf(“ d n“, x); 程序运行后的输出结果是 ( A) 1 7 ( B) 23 ( C) 24 ( D) 22 11 有以下程序 void
7、fun(int x, int y, int*c, int *d) *c=x+y; *d= x-y; main() int a=4, b=3, c=0, d=0; fun(a, b, &c, &d); printf(“ d d n“, c, d); 程序的输出结果是 ( A) 4 3 ( B) 3 4 ( C) 7 1 ( D) 0 0 12 有以下程序 void fun(int *p, int *q) int t; t= *p; *p= *q; *q=t; *q=*p; main() int a=0, b=9 ; fun(&a, &b); Ptintf(” d d n“, a, b); 程序的
8、输出结果是 ( A) 0 0 ( B) 9 9 ( C) 9 0 ( D) 0 9 13 有以下程序 char fun(ehar*c) if ( *c=A ) *c-= A一 a; return *c; main() char s81, *p=s; gets(s); while( *p ) *p=fun(p); putchar(*p); p+; printf(“ n“); 若运行时从键盘上输入 OPEN THE DOOR,程序的输出结果是 ( A) oPEN tHE dOOR ( B) open the door ( C) OPEN THE DOOR ( D) Open The Door 14
9、 有以下程序 void swap(char*x, char*y) char t; t=*x; *x=*y; *y=t; main( ) char, *s1=“abc“, *s2=“123“; swap(s1, s2); printf(“ s, s n“, s1, s2); 程序执行后的输出结果是 ( A) abc, 123 ( B) 123, abc ( C) 321, cba ( D) lbc, a23 15 有以下函数 int fun(char*x, char*y) int n=0; while(*x: =*y)&*x!= 0) x+; y+; n+; return n; 函数的功能是 (
10、 A)查找 x和 y所指字符串中是否有 0 ( B)统计 x和 y所指字符串中最前面连续相同的字符个数 ( C)将 y所指字符串赋给 x所指存储空间 ( D)统计 x和 y所指字符串中相同的字符个数 16 有以下函数 int fun(char*s)char*t=s; while(*t+); return(t-s); 该函数的功能是 ( A)比 较两个字符串的大小 ( B)计算 s所指字符串的长度 ( C)计算 s所指字符串占用内存字节的个数 ( D)将 s所指字符串复制到字符串 t中 17 有以下程序 (说明:字母 A的 ASCII码值是 65) void fun (char*s) while
11、( *s ) if(*s 2) printf(“ c“, *s); s+; main() char a=“BYTE“; fun(a); print=f(“ n“); ) 程序运行后的输出结果是 ( A) BT ( B) YE ( C) YT ( D) BY 18 有以下程序 #include void fun(char*p) +p; printf(“ s n“, *p); main() char*a=(“Morning“, “Afternoon“, “Evenng“, “Night“); fun(a); 程序的运行结果是 ( A) ftemoon ( B) Morning ( C) ornin
12、g ( D) Aftemoon 19 有以下程序 void funl(char*p) char*q; q=p; while(*q!= 0) (*q)+; q+; main_() char a=“Program“), *p; p=&a3; fun1(p); printf(“ s n“, a); 程序执行后的输出结果是 ( A) Prphsbn ( B) Prohsbn ( C) Progsbn ( D) Program 20 有以下程序 #include void fun(char*a, char*b) while(*a=*)a+; while(*b=*a)b+; a+; ) main() ch
13、ar*s=“*a*b*“, t80; fun(s, t); putS(t); 程序的运行结果是 ( A) a*b ( B) *a*b ( C) a*b* ( D) ab 21 下列函数的功能是 void fun(char*a, char*b) while(*b=*a)!= 0)a+; b+; ( A)使指针 b指向 a所指字符串 ( B)将 a所指字符串和 b所指字符串进行比较 ( C)将 a所指字符串赋给 b所指空间 ( D)检查 a和 b所指字符串中是否有 0 22 有以下程序 #include #include void fun(char s10, int n) char t; int
14、i, j; for(i=0; isj0)t=si0; si0=sj0; sj0=t; main() char ss510=“bcc“, “bbcc“, “xy“, “aaaacc“, “aabcc“); fun(s s, 5); printf(“ s, s n“, ss0, ss4 ; 程序的运行结果是 ( A) aaaacc, xy ( B) bcc, aabcc ( C) xy, aaaacc ( D) aabcc, bcc 23 有以下程序 #include void fun(char*t, char*s) while(*t!=0)t+; while(*t+ + =*s+ +)! =0)
15、, maiin_() char ss10=“acc“, aa10=“bbxxyy“; fun(ss, aa); printf(“ s, s n“, ss, aa); 程序的运行结果是 ( A) acc, bbxxyy ( B) accxxyy, bbxxyy ( C) accbbxxyy, bbxxyy ( D) accxyy, bbxxyy 24 有以下程序 #include #include void fun(char*w, int m) char s, *p1, *p2; p1=w; p2=w+m-1; while(p1 int b=2 ; int fun(intk) b=*k+b; r
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 语言 编译 预处理 指针 模拟 答案 解析 DOC
