网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
若有以下程序: include using namespace std; class sample { int x; public: sample

若有以下程序:

include <iostream>

using namespace std;

class sample

{

int x;

public:

sample(){}

void setx(int i)

{

x=i;

}

friend iht fun(sample B[],int n)

{

int m=0;

for{int i=0;i<n;i++)

if(B[i].x>m)

m=B[i].x;

return.m;

}

};

int main ( )

{

sample A[10];

int arr[]={90,87,42,78,97,84,60,55,78,65};

for(int i=O;i<10;i++)

A[i].setx(arr[i]);

cout<<fun(A, 10)<<end1;

return 0;

}

该程序运行后的输出结果是【 】。


参考答案

更多 “ 若有以下程序: include using namespace std; class sample { int x; public: sample 若有以下程序:include <iostream>using namespace std;class sample{int x;public:sample(){}void setx(int i){x=i;}friend iht fun(sample B[],int n){int m=0;for{int i=0;i<n;i++)if(B[i].x>m)m=B[i].x;return.m;}};int main ( ){sample A[10];int arr[]={90,87,42,78,97,84,60,55,78,65};for(int i=O;i<10;i++)A[i].setx(arr[i]);cout<<fun(A, 10)<<end1;return 0;}该程序运行后的输出结果是【 】。 ” 相关考题
考题 下列程序的执行结果是()。includeclass Sample{int x,y;public:Sample(){x=y=0;)Sam 下列程序的执行结果是( )。 #include<iostream.h> class Sample { int x,y; public: Sample(){x=y=0;) Sample(int a,int b){x=a;y=b;} ~Sample() { if=(x==y) cout<<“x=y”<<endl; else cout<<“x!=y”<<endl; } void disp() { coutA.x=2,y=2B.x=3,y=3C.x=2,y=3D.x=3,y=2

考题 分析以下程序的执行结果【】。includeclass Sample{int x, y;public:Sample() {x=y=0; 分析以下程序的执行结果【 】。include<iostream.h>class Sample{int x, y;public:Sample() {x=y=0; }Sample(int a, int b) { x=a; y=b;}~Sample(){if(x==y)cout<<"x=y"<<end1;elsecout<<"x!=y" <<end1;}void disp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main(){Sample s 1 (2,3);s1.disp();}

考题 以下程序的执行结果是【】。includeincludeclass Sample{ public: int x,y; 以下程序的执行结果是【 】。include<iostream.h>include<stdlib.h>class Sample{public:int x,y;Sample(){x=y=0;}Sample(int a,int b) {x=a;y=b; }void disp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main() {Sample s1(2,3);s1.disp();}

考题 以下程序的执行结果是 ( )。include using namespace std;class sample{private: int 以下程序的执行结果是 ( )。 #include <iostream> using namespace std; class sample { private: int x; public: sample (int A) { x=a; } friend double square(sample s); }; double square(sample s) {A.20B.30C.900D.400

考题 下列程序的运行结果是【 】。includeclass Sample{int a;public: Sample(int aa=0) {a 下列程序的运行结果是【 】。include<iostream, h>class Sample{int a;public:Sample(int aa=0) {a=aa;}~Sample() {cout<<"Sample="<<a<<;}class Derived: public Sample{int b;public:Derived(int aa=0, int bb=0): Sample(aa) {b=bb;}~De rived() {cout <<"Derived="<<b<<'';}void main(){Derived dl (9)}

考题 以下程序的执行结果是【 】。 include class Sample { public: int x: int y; void di 以下程序的执行结果是【 】。include<iostream. h>class Sample{public:int x:int y;void disp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main(){int Sample:: ** pc;Sample s;pc= Sample: :x;s.*pc=10;pc:=Sample: :y;s.*pc=20;s.disp();}

考题 有以下程序:includeusing namespace std;class sample{private:int x;public:sample( 有以下程序: #include<iostream> using namespace std; class sample { private: int x; public: sample(int A) { x=a; friend double square(sample s); }; double square(sample s) { return S.X*S.K; } int main() { saA.20B.30C.900D.400

考题 若有以下程序: include usingnamespace std; class Sample { private: const int n; 若有以下程序:include <iostream>using namespace std;class Sample{private:const int n;public:Sample(int i) :n(i) {)void print(){cout<<"n="<<n<<end1;}};int main(){sample a(10);a.print();return 0;}上述程序运行后的输出结果是【 】。

考题 若有以下程序:includeusingnamespaceStd;classsample{ inti;publiC: sample(){} void 若有以下程序: #include <iostream> using namespace Std; class sample { int i; publiC: sample(){} void setvalue(int m) { i=m; } void fun(int m) { i+=m; } void disp() { cout<<i<<end1; } }; int main() { sample *ps; ps=new sample; ps->setvalue(20); ps->fun(5); ps->disp(); return 0; } 程序运行后,输出的结果是( )。A.15B.20C.25D.30