以下程序输出的结果是( )。 #include<iostream> using namespace std; int main() { int **x,*y,z=10; y=&z; x=&y; cout<< **x+1<<endl; return 0; }
A.11
B.x的地址
C.y的地址
D.运行错误
第1题:
以下程序执行后的输出结果是( )。 #include <iostream> using namespace 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.不确定
第2题:
有如下程序:
#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.
第3题:
下面程序输出的结果是( )。 #include <iostream> using namespace std; void swap(int &a,int &b){ int temp; temp=a; a=b; b=temp; } void main(){ int x=2; int y=3; swap(x,y); cout<<x<<y; }
A.23
B.32
C.ab
D.ba
第4题:
有以下程序:
include <iostream>
using namespace std;
void t(int x,int y, int cp,int dp)
{
cp=x*x+y+y;
dp=x*x-y*y;
}
int main()
{
int a=4,b=3,c=5,d=6;
t(a,b,c,D) ;
cout<<c<<","<<d<<end1;
return 0;
第5题:
下面程序执行的结果是【 】
include<iostream>
using namespace std;
class A{
public:
static int x;
A(inty){cout<<x+y;}
};
int A::x=2;
void main(){
A a(5);
}
第6题:
请填写空格:
include<iostream>
using namespace std;
void fun(int x,int y,int * z)
{ *2 = x + y;}
void main()
{
int a=100,b=100,c,*p=&c;
fun(a,b,p);
【 】; //输出调用fun函数后返回a、b的和。
}
第7题:
以下程序执行后输出的结果是【 】。
include<iostream>
using namespace std;
int fac(int a,int b){
return(b-a)*a;
}
int main(){
int x=3,y=4,z=5,result;
result=fac(fac(x,y),fac(x,z));
cout<<result<<endl;
return 0;
}
第8题:
如下程序执行后的输出结果是【 】。
include <iostream>
using namespace std;
class Base
{
public:
Base(int x,int y)
{
a=x;
b=y;
}
void Show()
{
cout<<"Base: "<<a<< ',' <<b<<" ";
}
private:
int a,b;
};
class Derived : public Base
{
public:
Derived(int x, int y, int z) : Base(x,y),c(z) { }
void Show()
{
cout<<"Derived:"<<c<<end1;
}
private:
int c;
};
int main()
{
Base b(100,100),*pb;
Derived d(10,20,30);
pb=&b;
pb->Show();
pb=&d;
pb->Show();
return 0;
}
第9题:
以下程序执行后的输出结果是 #include <iostream> using namespace 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<<endl; 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.不确定
第10题:
下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }
A.34
B.43
C.33
D.44
第11题:
请选出以下程序段的输出结果 ( )。 #include <iostream> using namespace std; #define MIN(x,y) (x)<(y) ?(x) : (y) int main () { int i,j,k; i=10; j=15; k=10*MIN(i,j); cout<<k<<end1; return 0; }
A.15
B.100
C.10
D.150
第12题:
有如下程序:
include<iostream>
using namespace std;
int fun1(int x) {return++x;}
int fun2(int &x) {return++x;}
int main(){
int x=1,y=2;
y=fun 1(fun2(x));
cout<<X<<','<<y;
return 0:
}
程序的输出结果是______。
第13题:
有以下程序: #include <iostream> using namespace std; char *x[]={"First", "Second", "Third" }; void f(char *z[ ]) { cout<<*z++<<end1; } int main ( ) { char **y; y=x; f(y); return 0; }
A.产生语法错误
B.First
C.Secpnd
D.Third
第14题:
若有以下程序: #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
第15题:
以下程序输出结果是( ): #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
第16题:
下面程序的输出结果是【 】。
include <iostream>
using namespace std;
class A
{
int a, b;
public:
A()
{
a = b = 0;
}
A(int aa, int bb ) : a(aA) , b(bB)
{
cout <<"a="<<a<<","<<"b="<<b<<",";
}
~A()
{
cout<<"D";
};
int main ( )
{
A x, y(2, 3);
return 0;
}
第17题:
下列程序运行时的输出结果是______。
include<iostream>
using namespace std;
void Xfun(int&, int&);
int main(){
int a=3, b=4;
Xfun(a, B) ;
cout<<a*a+b<<end1;
return 0;
}
void Xfun(int& x, int& y){
int z=x;
x=y; y=z;
}
第18题:
若有以下程序: #include <iostream> using namespace std; class A { private: int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx () { return x; }; class B : protected A { public: void setvalue(int a, int b, int c) { setx (a); y=b; z=c; } void display() { cout<<getx ( ) <<", "<<y<<", "<<z<<", "<<end1; } }; int main () { B obj; obj.setvalue(5, 6, 7); obj.display ( ); return 0; } 程序运行后的输出结果是( )。
A.产生语法错误
B.7,6,5
C.5,6,7
D.7,5,6
第19题:
下面程序的运行结果是【 】。
include <iostream>
using namespace std;
void fun(int &a, int b=3)
{
static int i=2;
a = a + b + i;
i = i + a;
}
int main()
{
int x=5, y=2;
fun(x, y);
cout<<x<<",";
fun(x);
cout<<x<<end1;
return 0;
}
第20题:
下面程序输出的结果是( )。 #include<iostream> using namespace std; int fuc (char *x); int main(){ cout<<fuc("hello")<<endl; return 0; } int fuc(char *x){ char *y=x; while(*y! ='\0')y++; return(y-x); }
A.5
B.6
C.0
D.语法错误,不能输出结果
第21题:
以下程序执行后的输出结果是 #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.不确定
第22题:
以下程序执行后的输出结果是( )。 #include<iostream> using namespace 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<<endl; 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.不确定
第23题:
以下程序执行后的输出结果是 #include<iostream>. using namespace 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.不确定