[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷12及答案与解析.doc

上传人:wealthynice100 文档编号:499040 上传时间:2018-11-30 格式:DOC 页数:15 大小:43KB
下载 相关 举报
[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷12及答案与解析.doc_第1页
第1页 / 共15页
[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷12及答案与解析.doc_第2页
第2页 / 共15页
[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷12及答案与解析.doc_第3页
第3页 / 共15页
[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷12及答案与解析.doc_第4页
第4页 / 共15页
[计算机类试卷]国家二级C语言(编译预处理和指针)机试模拟试卷12及答案与解析.doc_第5页
第5页 / 共15页
点击查看更多>>
资源描述

1、国家二级 C语言(编译预处理和指针)机试模拟试卷 12及答案与解析 一、选择题 1 有以下程序 #include stdio.h void fun(int *a,int *b) int *c; c=a;a=b;b=c; main() int x=3,y=5,*p= fun(p,q);printf(“%d,%d,“,*p,*q); fun(printf(“%d,%dn“,*p,*q); 程序运行后的输出结果是 ( A) 3,5,5,3 ( B) 3,5,3,5 ( C) 5,3,3,5 ( D) 5,3,5,3 2 有下列程序: void f(int b ) int I; for(i=2; i

2、6; i+ +) bi*=2; main( ) int a10=1,2,3,4,5,6,7,8,9,10,i; f(a); for(i=0;i 10,i+ +)printf(“%d,“,ai); 程序运行后的输出结果是 ( A) 1,2,3,4,5,6,7,8,9,10, ( B) 1,2,3,4,10,12,14,16,9,10, ( C) 1,2,6,8,10,12,7,8,9,10, ( D) 1,2,6,8,10,12,14,16,9,10, 3 有以下程序 #include stdio.h int fun(char s ) int n=0; while(*s =9s+ +; retu

3、rn(n); main( ) char s10=6,1,*,4,*,9,*,0,*; printf(“%dn“,fun(s); 程序的运行结果是 ( A) 61490 ( B) 61 ( C) 9 ( D) 5 4 若有以下程序 #include stdio.h void sp(int *a) int b=2; a= *a = *a * 2; printf(“%d,“, *a); main() int k=3, *p= sp(p); printf(“%d,%dn“, k, *p); 则程序的输出结果是 ( A) 4,3,4 ( B) 4,3,3 ( C) 6,3,6 ( D) 6,6,6 5

4、若有以下程序 #include stdio.h int k=7; void f(int *s) int *t= *s=t; printf(“%d,%d,%d,“, k, *t, *s); main() int i=3, *p= f(r); printf(“%d,%d,%dn“, i, *p, *r); 则程序的输出结果是 ( A) 3,7,7,7,7,7 ( B) 7,7,7,3,3,3 ( C) 3,3,3,7,7,7 ( D) 7,7,7,3,7,7 6 若有以下程序 #include stdio.h int *f(int *s,int *t) int *k; if (*s *t) k =

5、 s; s=t; t=k; return s; main() int i=3, j=5, *p= r=f(p,q); printf(“%d,%d,%d,%d,%dn“, i, j, *p, *q, *r); 则程序的输出结果是 ( A) 3,5,5,3,5 ( B) 5,3,5,3,5 ( C) 5,3,3,5,5 ( D) 3,5,3,5,5 7 若有以下程序 #include stdio.h void sp(int *a) int b=2; *a = *a * 2; printf(“%d,“, *a); a= *a = *a * 2; printf(“%d,“, *a); main() i

6、nt k=3; sp( printf(“%dn“, k); 则程序的输出结果是 ( A) 6,4,6 ( B) 6,4,3 ( C) 6,12,12 ( D) 9,4,9 8 若有以下程序 #include stdio.h int k=7,m=5; void f(int *s) int *t= s= *s= printf(“%d,%d,%d,“, k, *t, *s); main() int i=3,*p= f(r); printf(“%d,%d,%dn“, i, *p, *r); 则程序的输出结果是 ( A) 7,5,7,3,3,3, ( B) 7,5,7,3,5,7, ( C) 7,5,5

7、,3,3,3, ( D) 7,7,5,3,3,3, 9 若有以下程序 #include stdio.h int *f(int *s, int *t) int k; if (*s *t) k = *s; *s=*t; *t=k; return s; main() int i=3, j=5, *p= r=f(p,q); printf(“%d,%d,%d,%d,%dn“, i, j, *p, *q, *r); 则程序的输出结果是 ( A) 3,5,5,3,5 ( B) 3,5,3,5,5 ( C) 5,3,5,3,5 ( D) 5,3,3,5,5 10 有以下程序 #include stdio.h

8、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(“%dn“, x ); 程序运行后的输出结果是 ( A) 17 ( B) 23 ( C) 24 ( D) 22 11 有以下程序 void fun( int x, int y, int *c, int *d ) *c =

9、x+y; *d = x-y; main() int a=4, b=3, c=0, d=0; fun ( a, b, printf( “%d %dn“ , 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 ( printf( “%d %dn“ , a,b ); 程序的输出结果是 ( A) 0 0 ( B) 9 9 ( C) 9 0 ( D) 0

10、 9 13 有以下程序 char fun( char *c ) if ( *c =Z 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 有以下程序 void swap(char *x,char *y) char t;

11、 t=*x; *x=*y; *y=t; main( ) char *s1=“abc“,*s2=“123“; swap(s1,s2); printf(“%s,%sn“,s1,s2); 程序执行后的输出结果是 ( A) abc,123 ( B) 123,abc ( C) 321,cba ( D) 1bc,a23 15 有以下函数 int fun(char *x, char *y) int n=0; while ( (*x=*y) y+; n+; return n ; 函数的功能是 ( A)查找 x和 y所指字符串中是否有 0 ( B)统计 x和 y所指字符串中最前面连续相同的字符个数 ( C)将

12、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( *s ) if( *s%2 ) printf(“%c“,*s); s+; main() char a =

13、“BYTE“; fun(a); printf(“n“); 程序运行后的输出结果是 ( A) BT ( B) YE ( C) YT ( D) BY 18 有 以下程序 #include stdio.h void fun(char * *p) + +p; printf(“%sn“, *p); main( ) char *a =(“Morning“,“Afternoon“,“Evening“,“Night“); fun(a); 程序的运行结果是 ( A) fternoon ( B) Morning ( C) orning ( D) Afternoon 19 有以下程序 void fun1(char

14、*p) char *q; q=p; while(*q! =0) (*q)+ +;q+ +; main( ) char a =“Program“, *p; p=fun1(p);printf(“%sn“,a); 程序执行后的输出结果是 ( A) Prphsbn ( B) Prohsbn ( C) Progsbn ( D) Program 20 有以下程序 #include stdio.h void fun(char *a,char *b) while(*a=*)a+; while(*b=*a)b+;a+; main() char *s=“*a*b*“,t80; fun(s,t);puts(t);

15、程序的运行结果是 ( 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 stdio.h #include string.h void fun(char s 10,int n) char t; int i,j; for(i=0;i n-1;i+

16、 +) for(j=i+1;j n;j+ +) if(si0 sj0)t=si0;si0=sj0;sj0=t; main( ) char ss510=“bcc“,“bbcc“,“xy“,“aaaacc“,“aabcc“; fun(ss,5); printf(“%s,%sn“,ss0,ss4); 程序的运行结果是 ( A) aaaacc,xy ( B) bcc,aabcc ( C) xy,aaaacc ( D) aabcc,bcc 23 有以下程序 #include stdio.h void fun(char *t,char *s) while(*t! =0) t+ +; while(*t+ +

17、 =*s+ +)! =0); main( ) char ss10=“acc“,aa10=“bbxxyy“; fun(ss,aa); printf(“%s,%sn“,ss,aa); 程序的运行结果是 ( A) acc,bbxxyy ( B) accxxyy,bbxxyy ( C) accbbxxyy,bbxxyy ( D) accxyy,bbxxyy 24 有以下程序 #include stdio.h #include string.h void fun(char *w,int m) char s,*p1,*p2; p1=w; p2=w+m-1; while(p1 p2)s=*p1; *p1=*

18、p2; *p2=s; p1+; p2-; main() char a=“123456“; fun(a,strlen(a); puts(a); ( A) 116611 ( B) 161616 ( C) 654321 ( D) 123456 25 有以下程序: #include stdio.h int b=2; int fun(int *k) b=*k+b;return(b); main() int a10=1,2,3,4,5,6,7,8,i; for(i=2;i 4;i+)b=fun(printf(“%d“,b); printf(“n“); 程序运行后的输出结果是 ( A) 8 10 ( B)

19、10 28 ( C) 10 12 ( D) 10 16 26 有以下程序 #include stdio.h #include string.h void fun( int *p1, int *p2, int *s) s=( int*)calloc(1,sizeof(int); *s=*p1+*p2; free(s); main() int a2=1,2, b2=40,50,*q=a; fun(a,b,q); printf(“%dn“, *q); 程序运行后的输出结果是 ( A) 41 ( B) 42 ( C) 0 ( D) 1 国家二级 C语言(编译预处理和指针)机试模拟试卷 12答案与解析

展开阅读全文
相关资源
猜你喜欢
相关搜索

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

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