若有如下程序: sub(int x) {int y=0; static int z=1; y+=x+2;z+=y+x; return(z); } main() {int t=1,n; for(n=0;n<3;n++)printf("%d,",sub(t)); } 则程序运行后的输出结果是 ( )
A.5,5,5
B.5,9,13,
C.5,7,9,
D.5,8,11,
第1题:
有以下程序
#include <stdio.h>
int f(int x)
{ int y;
if(x==0||x==1) return(3);
y=x*x-f(x-2);
return y;
}
main()
{ int z;
z=f(3); printf("%d\n",z);
}
程序的运行结果是
A.0
B.9
C.6
D.8
第2题:
若有以下程序段: #include <iostream> using namespace std; int main () { int a[]={1,4,5}; int *p=&a[0],x=6, y,z; for (y=0; y<3; y++) z= ( (* (p+y) <x) ? *(p+y) :x); cout<<z<<end1; return 0; } 程序运行后的输出结果是( )。
A.1
B.4
C.5
D.2
第3题:
有如下程序: #include <stdio.h> int func(int a,int b) { return(a+b):} main() { int x=2,y=5,z=8,r; r=func(func(x,y),z); printf("%d\n",r); } 该程序的输出结果是( )。
A.12
B.13
C.14
D.15
第4题:
有以下程序: #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(x>y) f(x,y); else if(y>z) f(y,z); else f(x,z); printf("%d,%d,%d\n",x,y,z); } 执行后的输出结果( )。
A.1,2,3
B.3,1,2
C.1,3,2
D.2,3,1
第5题:
以下程序输出结果是( ): #include<iostream> using namespace std; void add(int X,int y,int *z) { *z=y+x; } int main() { int a,b,c; add(8,4,&a); add(6,a,&b); add(a,b,&c); cout<<a<<","<<b<<","<<c<<end1; return 0;
A.12,10,14
B.12,18,30
C.12,6,18
D.12,14,30
第6题:
若有如下程序: sub(int a,int b,int c) { c=a+b; return(c);} main() {int x=3,y=4,z=6; sub(x,y,z); printf('%d”,z); } 则程序运行后的输出结果是( )。
A.3
B.6
C.7
D.4
第7题:
有下列程序: #include <stdio.h> int f(int x) { int y; if(x=0‖x==1)return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3);printf("%d\n",z); 程序的运行结果是( )。
A.0
B.9
C.6
D.8
第8题:
若有以下程序段; #include<iostream> using namespace std; int main() { int a[]={1,4,5}; int *p=&a[0],x=6,y,z; for(y=0;y<3;y++) z=((*(p+y)<x) ? *(p+y):x); cout<<z<<end1; return 0; } 程序运行后的输出结果是( )。
A.1
B.4
C.5
D.2
第9题:
若有以下程序:# include <iostream>using namespace std;void sub(int x, int y, int *z){ *z = y+x;}int main (){ int a,b, c; sub[8,4.&a) ; sub (6, a, &b) ; sub (a.b, &c) ; cout<<a<<" , "<<b<<", "<<c<<end1; return 0;} 程序运行后的输出结果是
A.12,18,30
B.-12,6,8
C.6,8,10
D.12,-18,16
第10题:
以下程序执行后的输出结果是 #include<iostream> using namcspace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }
A.18
B.9
C.10
D.不确定
第11题:
若有以下程序: #include<iostream> usingnamespacestd; voidsub(intx,inty,int*2) { *z=y+x; } int main() { int a,b,C; sub(8,4,&A) ; sub(6,a,&B) ; sub(a,b,&C) ; cout<<a<<","<<b<<","<<c<<end1; return 0; }
A.12,18,30
B.-12,6,8
C.6,8,10
D.12,-18,16
第12题:
0
9
6
8
第13题:
使用VC6打开老考生文件夹下的工程test5_1,此工程包含一个源程序文件test5_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:
x=3 y=5 z=0
8
源程序文件test5_1.cpp清单如下:
include<iostream.h>
static int x=5;
int z=0;
int *add(int x,int y)
{
cout<<"X="<<X<<"y="<<y<<" Z="<<z<<endl;
z=z+x+y;
/********found*********/
return z;
/********found*********/
};
void main()
{
int y=5;
int x=3;
/*********found********/
cout<<&(add(X,y))<<endl;
}
第14题:
下面程序的结果【 】。
include<iostream.h>
int f(int);
void main() {
int x=1, i;
for (i=0; i<3; i++)
cout<<f(x)<<‘ ’ ;
cout<<end1;
}
int f(int x){
int y=1;
static int z=3
y++;
z++;
return (x+y+z);
}
第15题:
有如下程序:
#include<iostream>
using namespace std;
void f1(int& x, int& y){int z=x; x=y; y=z;)
void f2(int x, int y){int z=x; x=y; y=z;}
intmain(){
int x=10, y=26;
f1(x, y);
f2(x, y);
cout<<y<<end1;
return 0;
}
运行时的输出结果是( )。
A) 10
B) 16
C) 26
D) 36
A.
B.
C.
D.
第16题:
若有以下程序: #include <iostream> using namespace std; void sub(int x,int y, int *z) { *z = y+x; } int main() { int a,b, c; sub (8,4,&a) ; sub (6, a, &b) ; sub(a,b,&c) ; cout<<a<<", "<<b<<", "<<c<<end1; return 0; } 程序运行后的输出结果是( )。
A.12,18,30
B.-12,6,8
C.6,8,10
D.12,-18,16
第17题:
若有程序: fun(int a,int b) { static int c=0; c+=a+b: return c; } main() { int x=5,y=3,z=7,r; r=fun((y,x+y),z); r=fun(x,y); printf("%d\n",r); } 上面程序的输出结果是______。
A.23
B.15
C.19
D.18
第18题:
有以下程序 #include <stdio.h> intf(int x) { int y; if(x==0||x==1) return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3); printf("%d\n",z); } 程序的运行结果是
A.0
B.9
C.6
D.8
第19题:
有以下程序 #include <stdio.h> int f(int x) { int y; if(x==0||x==1) return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3); printf("%d\n",z); } 程序的运行结果是
A.0
B.9
C.6
D.8
第20题:
若有程序 fun(int a,int b} { static int c=0; c+=a+b; return c; } main() { int x=5,y=3,z=7,r, r=fun(y,x+y),z); r=fun(xy); printf("%d\n",r); } 上面程序的输出结果是_____。
A.23
B.15
C.19
D.18
第21题:
若有如下程序: int sub() {static int n=1; int x=1; x*=n;n++; return x; } main() {int n,t=1; for(n=1;n<6;n++)t*=sub(); printf("%d\n",t); } 则程序运行后的输出结果是( )
A.15
B.120
C.34560
D.-30976
第22题:
若有如下程序: sub(int a,int b,int *z) {*z=a+b; return;} main() {int a=1,b=2,c=3,d,e; sub(a,b,&D) ; sub(c,d,&e); printf("%d",e); } 则程序运行后的输出结果是
A.3
B.4
C.5
D.6
第23题:
若有程序fun(int a, int b){ static int c=0; c+=a+ b; returm c;}main(){ int x=5,y=3,z=7,r; r=fun((y, x+ y),z); r=fun (x, y); printf("%d\n", r);}
A.23
B.15
C.19
D.18