单项选择题
以下程序执行后的输出结果是( )。
#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.不确定
点击查看答案
<上一题
目录
下一题>
热门
试题
单项选择题
有如下程序: #include <iostream> using namespace std; class Complex double re, im, public: Complex(double r, double i): re(r), im(i) double real() const return re; double image() const return im, Complex& operator +=(Complex a) re +=a.re; im +=a.im; return *this; ; ostream& operator << (ostream& s, const Complex& z) return s<<’(’<<z.real()<<’,’<<z.image()<<’)’; int main() Complex x(1,-2), y(2,3); cout << (x+=y) << endl; return 0; 执行这个程序的输出结果是( )。
A.(1,-2)
B.(2,3)
C.(3,5)
D.(3,1)
点击查看答案
单项选择题
对于下面定义的类MyClass,在函数f()中将对象成员n的值修改为50的语句应该是( )。 class MyClass public: MyClass(int x) n=x; void SetNum(int n1) n=n1; private: int n; int f() MyClass *ptr=new MyClass(45);
A.MyClass(50)
B.SetNum(50)
C. ptr->SetNum(50)
D. ptr->n=50
点击查看答案
相关试题
以下程序的输出的结果是( )。 #includ...
有如下程序: #include<iostream> usi...
若有以下程序: #include <iostream>...