有如下程序: #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
有如下程序: #inClude<iostream> 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.x<2)return l; return S.X*fun(Sample(s.x-1)); } int main( ) { int sum=0; for(int i=0;i<6;i++) {sum+=fun(Sample(i));} Cout<<sum: return 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
有如下程序: 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
有以下程序includeint i=0;void fun(){{ Static int i=1 Std::cont 有以下程序 #include<iostream,h> int i=0; void fun() { { Static int i=1 Std::cont<<i++<<','; } Std::cout<<i<<','; } int main() { fun();fun(); return 0; } 程序执行后的输出结果是( )。A.1,2,1,2,B.1,2,2,3,C.2,0,3,0,D.1,0,2,0,
有以下程序: include int i=0;void fun(){{static iht i=1; std::cout 有以下程序: # include <iostream> int i=0; void fun() {{static iht i=1; std::cout<<i++<<','; } std:: cout<<i<<','; } int main() { fun(); fun(); return 0; }程序执行后的输出结果是______。A.1,2,1,2,B.1,2,2,3,C.2,0,3,0,D.1,0,2,0,
使用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);}
有如下程序:includeusing namespace std;int s=0;class sample{ static int n;public 有如下程序: #include<iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=0; int main() { sample a(2),b(5); sample::add(); cout<<s<<endl; return 0; } 程序运行后的输出结果是A.2B.5C.7D.3
完成下面的程序,使显示结果如下图所示。Private Sub Form_Click()FontSize=18Sample$s="【 】"x=(ScaleWidth-TextWidth(Sample$))/2y=(ScaleHeight-TextHeight(Sample$))/2CurrentX=xCurrentY=y【 】Sample$End Sub
有以下程序include int i = 0;void fun( ){ {static int i = 1;std::cout 有以下程序 #include <iostream> int i = 0; void fun( ) { { static int i = 1; std::cout<<i++<<','; } std::cout<<i<<','; } int main() { fun(); fun(); return 0; } 程序执行后的输出结果是A.1,2,1,2,B.1,2,2,3,C.2,0,3,0,D.1,0,2,0,
若有如下程序:include using namespaces std;int s=0;class sample {static iht n;pu 若有如下程序: #include <iostream> using namespaces std; int s=0; class sample { static iht n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=0; int main() { sample a(2),b(5); sample::add(); cout<<s<<endl; return 0; } 程序运行后的输出结果是A.2B.5C.7D.3