有以下程序: #include <iostream> using namespace std; int f1(int x, int y) { return x>y ? x:y; } int f2(int x, int y) { return x>y? y:x; } int main ( ) { int a = 4,b = 3,c = 5,d,e,f; d = f1(a,b) ; d = f1(d,c) ; e = f2 (a,b) ; e = f2(e,c) ; f = a+b+c-d-e; cout<<d<<", "<<e<<", "<<f<<end1; return 0; } 执行后的输出结果是 ( )。
A.3,4,5
B.5,3,4
C.5,4,3
D.3,5,4
第1题:
若有以下程序段: #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
第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;
int funl(int x){return++x;}
int fun2(int&x){return++x;}
int main( ){
int x:1,y=2;
Y=funl(fun2(x));
cout<<x<<','<<y;
return 0;
}
第4题:
有以下程序: #include <iostream> using namespace std; class myclass { private: int a, b; public: void init( int i, int j ) { a = i; b = j; } friend int sum( myclass x ); }; int sum( myclass x ) { return x.a + x.b; } int main () { myclass y; y.init( 15, 20 ); cout<<sum( y )<<end1; return 0; } 执行后的输出结果是( )。
A.15
B.20
C.5
D.35
第5题:
有如下程序: #include <iostream.h> #include <iomanip.h> using namespace std; class CSum { int x,y; public: CSum (int x0,int y0):x(x0),y(y0){} friend ostream & operator<<(ostream& os,const CSum& xa) { os<<setw(5)<<xa.x+xa.y; return os; } }; int main () { CSum y(3,5); cout<<setfill ('*')<<8; cout<<y; return 0; } 执行上面程序的输出是
A.88
B.****88
C.****8****8
D.8****8
第6题:
以下程序执行后的输出结果是( )。 #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.不确定
第7题:
若有以下程序: #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
第8题:
若有以下程序:
include <iostream>
using namespace std;
int f(int x, int y)
{
return (y-x)*x;
}
int main()
{
int a=3,b=4,c=5,d;
d=f(f(a,b) ,f(a,c) );
cout<<d<<<end1;
return 0;
}
执行后的输出结果是【 】。
第9题:
下面程序输出的结果是( )。 #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
第10题:
有以下程序:
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;