网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
( 35 )有如下程序::
#include
using namespace std:
class Sample
{
friend long fun ( Sample s ) ;
public:
Sample ( long a ) {x=a;}
Private:
long x;
};
long fun ( Sample s )
{
if ( s.x<2 ) retum 1;
retum s.x*fun ( Sample ( s.x-a ))
}
int main ()
{
int sum=0
for ( int i =0; i <6; i ++ ) { sum+=fun ( Sample ( i ) ; ) }
cout<<SUM;
retum 0;
}
运行时输出的结果是
A ) 120
B ) 16
C ) 154
D ) 34
参考答案
更多 “ ( 35 )有如下程序::#includeusing namespace std:class Sample{friend long fun ( Sample s ) ;public:Sample ( long a ) {x=a;}Private:long x;};long fun ( Sample s ){if ( s.x2 ) retum 1;retum s.x*fun ( Sample ( s.x-a ))}int main (){int sum=0for ( int i =0; i 6; i ++ ) { sum+=fun ( Sample ( i ) ; ) }coutSUM;retum 0;}运行时输出的结果是A ) 120B ) 16C ) 154D ) 34 ” 相关考题
考题
有如下类定义,请将Sample类的复制构造函数补充完整。class Sample{public:Sample( ){ }~Sample( ){if(P)delete P;)Sample(const Samples){______}void SetData(int datA) {P=new int(datA) ;}private:int*P:};
考题
下列定义中,Sample是一个类,( )是定义指向对象数组的指针p.A.Sample*P [5]B.Sample (*p) [5]C.(Sample*) P[5]D.Sample *P[]
考题
有如下程序: include using namespace std; class Sample { frien
有如下程序: #include <iostream> using namespace std; class Sample { friend long fun(Sample s); public: Sample(long a) {x=a;} private: long x; }; long fun(Sample s) { if(s.x < 2) return 1; return s.x * fun(Sample(s.x-1)); } int main() { int stun = 0; for (int i=0; i<6; i++) {sum += fun(Sample(i));} cout << sum; return 0; }运行时输出的结果是A.120B.16C.154D.34
考题
有如下类定义,请将Sample类的拷贝构造函数补充完整。class Sample{public:Sample(){)~Sample(){if(p)delete p;)Sample(const Sample s){______}void SetData(int data) {p=new int(data);}private:int*p;};
考题
使用VC6打开考生文件夹下的工程test12_1,此工程包含一个源程序文件test_12.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果如下:fun (Sample p) 1 2fun (Sample *p) 3 420 10源程序文件test12_1清单如下:include<iostream .h>class Sample{private:int x,y;static int z;public:Sample(int a,int b){ x=a;y=b; }void fun(Sample p);void fun(Sample *p);static void print(Sample s);};/*************** found ***************/int z=10;void Sample::fun(Sample p){x=p.K;y=p.y;cout<<"fun(Sample p)"<<" "<<x<<" "<<y<<endl;}void Sample::fun(Sample *p){/************** found **************/x=p.x; y=p.y;cout<<"fun(Sample *p) "<<" '<<x<<" "<<y<<endl;}void Sample::print (Sample s){/*************** found *****************/x=20;cout<<s. x<<" "<<z<<endl;}void main(){Sample p(1,2),q(3,4);p. fun(p);p. fun(q);p. print(p);}
考题
有如下程序: #inCludeiostream using namespaCe std; Class Sample{ friend long fun(Sample S); publiC: Sample(10ng A.{x=a;} private: long X; }; long fun(Sample S){ if(S.x2)return l; return S.X*fun(Sample(s.x-1)); } int main( ) { int sum=0; for(int i=0;i6;i++) {sum+=fun(Sample(i));} Coutsum: return 0; } 执行这个程序的输出结果是( )。A.120B.16C.154D.34
考题
完成下面的程序,使显示结果如下图所示。Private Sub Form_Click()FontSize=18Sample$s="【 】"x=(ScaleWidth-TextWidth(Sample$))/2y=(ScaleHeight-TextHeight(Sample$))/2CurrentX=xCurrentY=y【 】Sample$End Sub
考题
若有如下程序: include using namespaces std;int s=O;class sample {static int n;p
若有如下程序: #include <iostream> using namespaces std; int s=O; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=O; int main() { sample a(2),b(5); sample: :add(); cout<<s<<end1; return 0; } 程序运行后的输出结果是A.2B.5C.7D.3
考题
有如下类定义,请将Sample类的拷贝构造函数补充完整。 class Sample { public: Sample(){} ~Sample(){if(p)delete p;} Sample(const Samples){ p=new int; *p=___________; } void SetData(int data) {p=new int(data);} void print(){cout<<*p<<endl;} private: int*p; };
热门标签
最新试卷