高级C语言程序员测试Word下载.docx
《高级C语言程序员测试Word下载.docx》由会员分享,可在线阅读,更多相关《高级C语言程序员测试Word下载.docx(18页珍藏版)》请在冰点文库上搜索。
A3,B5,C6,D7。
3.
intfoo3(intx,inty)
intval;
val=1;
if(y>
0){
if(n%2==1)val=val*x;
val=val*foo3(x*x,y/2);
returnval;
该函数功能:
Ax的y次方,
By的x次方,
Cx的2y次方,
D以上都不对。
4.
voidfun4()
inta[5]={1,2,3,4,5};
int*ptr=(int*)(&
a+1);
%d,%d\n"
*(a+1),*(ptr-1));
A2,2,B2,1,C2,5,D以上都不对。
5.
voidfun5()
voidfoo5(intb[][3]);
inta[3][3]={{1,2,3},{4,5,6},{7,8,9}};
foo5(a);
a[2][1]);
voidfoo5(intb[][3])
{
++b;
b[1][1]=9;
A8,B9,C7,D以上都不对。
6.
voidfun6()
inta,b,c,d;
a=3;
c=a,b;
d=(a,b);
c=%d,"
c);
d=%d\n"
d);
Ac=3,d=3,Bc=5,d=3,Cc=3,d=5,Dc=5,d=5。
7.
voidfun7()
inta[][3]={1,2,3,4,5,6};
int(*ptr)[3]=a;
%d,%d,"
(*ptr)[1],(*ptr)[2]);
++ptr;
%d,%d\n"
A2,3,5,6,B2,3,4,5,C4,5,0,0,D以上都不对。
8.
int*f1(void){
intx=10;
return(&
x);
int*f2(void){
int*ptr;
*ptr=10;
returnptr;
int*f3(void){
int*ptr;
ptr=(int*)malloc(sizeof(int));
以上3个函数有可能出错的是
Af3,Bf1和f3,Cf1和f2,Df1,f2和f3。
9.
voidfun9()
inti=3;
intj;
j=sizeof(++i+++i);
i=%d,j=%d"
i,j);
Ai=4,j=2,Bi=3,j=2,Ci=3,j=4,Di=3,j=6。
10.
voidfun10()
voidfoo101(int*,int);
voidfoo102(int*,int);
void(*p[2])(int*,int);
p[0]=foo101;
p[1]=foo102;
p[0](&
a,b);
%d\t,%d\t,"
a,b);
p[1](&
%d\t,%d\t\n"
voidfoo101(int*p,intq)
inttmp;
tmp=*p;
*p=q;
q=tmp;
voidfoo102(int*p,intq)
A5,5,5,5,B3,5,3,5,C5,3,5,3,D3,3,3,3。
11.
voidfun11()
voidfoo11(int);
inta=3;
foo11(a);
\n"
);
voidfoo11(intn)
if(n>
0){
foo11(--n);
%d,"
n);
A0,1,2,0,B0,1,2,1,C1,2,0,1,D0,2,1,1。
12.
typedefint(*test)(float*,float*);
testtmp;
tmp类型是:
A包括两个浮点数指针的函数指针,
Bint,
C包括两个浮点数指针和返回整型的函数指针,
D函数。
13.
voidfun13()
intp;
intbuf[10]={1,2,3,4,5,6,9,8};
p=(buf+1)[5];
p);
A5,B6,C9,D以上都不对。
14.
voidfun14()
voidfoo14(char**);
char*argv[]={"
ab"
"
cd"
"
ef"
gh"
"
ij"
kl"
foo14(argv);
voidfoo14(char**p)
char*t;
t=(p+=sizeof(int))[-1];
printf("
%s\n"
t);
Aab,Bcd,Cef,Dgh。
15.
voidfun15()
intfoo15(int,...);
intnum;
num=foo15(3,5,7);
num);
intfoo15(intn,...)
inti,j;
intk;
va_listp;
k=0;
j=1;
va_start(p,n);
for(;
j<
n;
++j){
i=va_arg(p,int);
i;
i&
=i-1)++k;
returnk;
A7,B6,C5,D3。
16.
voidfun16()
intfoo16(inti);
for(i=0;
i<
=5;
i++)j=foo16(i);
j);
intfoo16(inti)
staticintcount=0;
count=count+i;
return(count);
A10,B15,C6,D7。
以下是程序实验源代码:
#include<
stdio.h>
stdarg.h>
voidfun1(void);
voidfun2(void);
voidfun3(void);
voidfun4(void);
voidfun5(void);
voidfun6(void);
voidfun7(void);
voidfun8(void);
voidfun9(void);
voidfun10(void);
voidfun11(void);
voidfun12(void);
voidfun13(void);
voidfun14(void);
voidfun15(void);
voidfun16(void);
intmain(intargc,char*argv[])
The1result:
"
fun1();
The2result:
fun2();
The3result:
fun3();
The4result:
fun4();
The5result:
fun5();
The6result:
fun6();
The7result:
fun7();
The8result:
fun8();
The9result:
fun9();
The10result:
fun10();
printf("
The11result:
fun11();
The12result:
fun12();
The13result:
fun13();
The14result:
fun14();
The15result:
fun15();
The16result:
fun16();
return0;
voidfun3()
intfoo3(intx,inty);
intx;
inty;
x=2;
for(y=1;
y<
=5;
y++){
x=2;
y=%d;
rst=%3d\n"
y,foo3(x,y));
if(y%2==1)val=val*x;
voidfun8()
i=%d,j=%d\n"
voidfun12()
intfoo12(float*a,float*b);
testtemp;
floata;
floatb;
a=1.0;
b=2.0;
temp=foo12;
temp(&
a,&
b);
%f,%f\n"
a,b);
intfoo12(float*a,float*b)
floattmp;
tmp=*a;
*a=*b;
*b=tmp;
return1;
Linux下的运行结果:
5
3
y=1;
rst=2
y=2;
rst=4
y=3;
rst=8
y=4;
rst=16
y=5;
rst=32
2,5
9
c=3,d=5
2,3,5,6
i=3,j=4
5,5,5,5
0,1,2,0,
2.000000,1.000000
gh
5
15