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

题目内容 (请给出正确答案)

下面程序执行后的输出结果是()。 using System; class Program { static long fib(int n) { if (n > 2) return (fib(n - 1) + fib(n - 2)); else return (2); } static void Main() { Console.WriteLine("{0}", fib(3)); } }

A.2

B.4

C.6

D.8


参考答案和解析
A 解析: strcpy(a,'are')中数组名a代表数组首地址的地址常量,该操作把are复制到a中,a[0][3]='&',且strcpy(a[1],'you')把you复制到a[1]中,故输出a为“are&you”。
更多 “下面程序执行后的输出结果是()。 using System; class Program { static long fib(int n) { if (n > 2) return (fib(n - 1) + fib(n - 2)); else return (2); } static void Main() { Console.WriteLine("{0}", fib(3)); } }A.2B.4C.6D.8” 相关考题
考题 以下程序运行结果是【8】 。long fib (int g){ switch (g){ case 0∶return 0;case 1∶case2∶return 1;}return (fib (g-1)+fib(g-2));}main (){ long k;k=fib (5);printf ("k=%(d\n)",k);}

考题 有如下程序:long fib(int n){ if(n2)return(fib(n-1)+fib(n-2));else return(2);}main(){ printf("%d\n",fib(3));}该程序的输出结果是A.2B.4C.6D.8

考题 有以下面程序: include using namespace std; long fib(int n) { if (n>2)return (fi 有以下面程序:include <iostream>using namespace std;long fib(int n){if (n>2)return (fib(n-1)+fib(n-2));elsereturn 2;}int main(){cout<<fib(3)<<endl;return 0;}则该程序的输出结果应该是【 】。

考题 下面程序的运行结果是【】。 inChlde using namespace std; class count { static int n; 下面程序的运行结果是【 】。inChlde<iOStream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0:i<4;i++)n++;return n;}};int count::n=0;int main(){cout<<COUnt::test()<<" ";count c1, c2;cout<<count::test()<<end1;return 0;}

考题 阅读下面程序:include long fib(int n){if (n>2)return (fib(n-1) + fib(n-2));else 阅读下面程序:include <iostream.h>long fib(int n){if (n>2)return (fib(n-1) + fib(n-2));elsereturn (2);}void main(){cout<<fib(3)<<end1;}则该程序的输出结果应该是【 】。

考题 ( 21 )计算斐波那契数列第 n 项的函数定义如下:Int fib(int n){if (n == 0) return 1;else if (n == 1) return 2;else return fib(n-1)+fib(n-2);}若执行函数调用表达式 fib(2) ,函数 fib 被调用的次数是A ) 1B ) 2C ) 3D ) 4

考题 阅读下面程序: include using namespace std; long fib(int n) {if(n > 2) return(fib 阅读下面程序:include<iostream>using namespace std;long fib(int n){if ( n > 2 )return (fib(n-1)+fib(n-2));elsereturn 2;}int main(){cout<<fib(3)<<end1;return 0;{则该程序的输出结果应该是【 】。

考题 下面程序的运行结果是【】。 include using namespace std; class count{ static int n; 下面程序的运行结果是【 】。include <iostream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0;i<4;i++)n++;return n;}};int count::n = O;int main(){cout<<count:: test()<<" ";count c1, c2;cout<<count:: test()<<endl;return 0;}

考题 若有如下程序:include using namespaces std;int s=0;class sample{static int n;pub 若有如下程序:#include <iostream>using namespaces std;int s=0;class sample{static int n;public:sample(int i){ n=i;}static void add(){ s+=n;}};int sample:: n=0;int main(){sample a(2),b(5);sample:: add();cout<<s<<end1;return 0;}程序运行后的输出结果是( )。A.2B.5C.7D.3

考题 有如下程序: include using namespace std; class Test { public 有如下程序: #include<iostream> using namespace std; class Test { public: Test(){n+=2;} ~Test(){n-=3;} static int getNum(){return n;} private: static int n; }; int Tesl::n=1 int main() { Test*p=new Test; delete p; cout<<"n="<<Tes::tgetNum()<<endl; return 0; } 执行后的输出结果是A.n=0B.n=1C.n=2D.n=3

考题 阅读下面利用递归来求n!的程序 class FactorialTest { static long Factorial(int n){ //定义Factorial()方法 if(n==1)return 1; else return n * Factorial(______); } public static void main(String a[]) { //main()方法 int n=8; System.out.println(n+"!="+Factorial(n)); } } 为保证程序正确运行,在下画线处应该填入的参数是A.n-1B.n-2C.nD.n+1

考题 有如下程序: include using namespace std; class Test{ public: Tes 有如下程序: #include<iostream> using namespace std; class Test{ public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test; delete p; cout<<"n="<<Test::getNum()<<endl; return 0; } 执行后的输出结果是( )。A.n=0B.n=1C.n=2D.n=3

考题 有如下程序:includelong fib(int n){if(n>2)return(fib(n-1)+fib(n-2)); else retu 有如下程序: #include<iostream.h> long fib(int n) { if(n>2)return(fib(n-1)+fib(n-2)); else return(2);} void main( ) {cout<<fib(3);} 该程序的输出结果是A.2B.4C.6D.8

考题 计算斐波那契数列第n项的函数定义如下:int fib(int n){if(n==0) return 1;else if(n==1)return 2;else return fib(n-1)+ilb(n-2);}若执行函数调用表达式fib(2),函数fib被调用的次数是A.1B.2C.3D.4

考题 有如下程序:includelong fib(int n){if(n>2) return(fib(n-1) +fib(n-2) ) ; else 有如下程序: #include<iostream.h> long fib(int n) { if(n>2) return(fib(n-1) +fib(n-2) ) ; else return(2) ;} void main( ) { cout < < nb(3) ;} 该程序的输出结果是A.2B.4C.6D.8

考题 如下程序的输出结果是includeusing namespace std;class Test{public:Test( ){n+=2;} 如下程序的输出结果是 #include<iostream> using namespace std; class Test{ public: Test( ){n+=2;} ~Test( ){n-=3;} static int getNum( ){return n;} private: static int n; }; int Test::n=1; int main( ){ Test*P=new Test: delete P; cout<<"n="<<Test::getNum( )<<endl; return 0; }A.n=0B.n=1C.n=2D. n=3

考题 有如下程序:includelong fib(int n){if(n>2)return(fib(n-1)+fib(n-2)); else return( 有如下程序: #include <stdio.h> long fib(int n) { if(n>2)return(fib(n-1)+fib(n-2)); else return(2); } main() { printf("%d\n",fib(3));} 该程序的输出结果是( )。A.2B.4C.6D.8

考题 有如下程序:include usingnamespacestd:class Test{public: Test(){n+=2; ~Test(){n- 有如下程序:#include <iostream>using namespace std:class Test{public: Test() {n+=2; ~Test() {n-=3; ; static int getNum() {return n;}privaue: static int n:};int Test::n=1;int main(){ Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<end1; return 0;} 执行后的输出结果是A.n=0B.n=1C.n=2D.n=3

考题 计算斐波那契数列第n项的函数定义如下: intfib(intn){ if.(n==0)return1; elseif(n==1)return2: elsereturnfib(n-1)+fib(n-2); } 若执行函数调用表达式fib(2),函数fib被调用的次数是( )。A.1B.2C.3D.4

考题 有如下程序 long fib(int n) { if(n>2)return(fib(n-1)-fib(n-2)); else return(1); } main() { printf("%d\n",fib(5)); }该程序的输出结果是______。A.-3B.-2C.-1D.0

考题 有如下程序:include using namespace std;class Test{public:Test(){n+=2; }~Test(){ 有如下程序: #include <iostream> using namespace std; class Test { public: Test() {n+=2; } ~Test() {n-=3; } static int getNum() {return n; } private: static int n; }; int Test::n=1; int main() { Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<endl; return 0; } 执行该程序的输出结果是( )。A.n=0B.n=1C.n=2D.n=3

考题 有如下程序______。 long fib (int n) { if(n>2) returb(fib(n-1)+fib(n-2)); else return(2); } main() {printf("%d\n",fib(3));} 该程序的输出结果是______。A.2B.4C.6D.8

考题 阅读下列利用递归来求n!的程序。 class FactorialTest{ static long Factorial(int n){//定义Factorial方法 if(n= =1) return l; else return n*Factorial{ }; } public static void main{String a[]}{ //main方法 int n=8: System.out.println{n+"!="+Factorial (n)}; } } 为保证程序正确运行,在下画线处应该填入的参数是( )。A.n-1B.n-2C.nD.n+1

考题 有程序: long fib(int n) { if(n<2)return(fib(n-1)+fib(n-2)); else return(2); } main( ) {printf("%d\n",fib(3));} 该程序的输出结果是( )A.2B.4C.6D.8

考题 有如下程序:includeusing namespace std;long fib(int n){ if(n>2) return(fib(n-1)+ 有如下程序: #include<iostream> using namespace std; long fib(int n) { if(n>2) return(fib(n-1)+fib(n-2)); else return(n); } void main() { int i; cout<<"请输入一个整数:"; cin>>i;cout<<endl; cout<<fib(i)<<endl; { 当输入4、2时,该程序的输出结果是( )。A.5B.4C.5D.6 1 2 2 2

考题 有以下程序 include using namespace std; long fib(int n) { if(n>2) return(fib(n-1 有以下程序include<iostream>using namespace std;long fib(int n){if(n>2)return(fib(n-1)+fib(n-2));elsereturn 2;}int main( ){cout<<fib(3)<<endl;return 0;}则该程序的输出结果应该是______。

考题 有如下程序 long fib(int n) { if(n2) return(fib(n-1)+fib(n-2)); else return(2); } main() { printf("%ld/n",fib(3)); } 该程序的输出结果是()A、2B、4C、6D、8

考题 单选题有如下程序 long fib(int n) { if(n2) return(fib(n-1)+fib(n-2)); else return(2); } main() { printf("%ld/n",fib(3)); } 该程序的输出结果是()A 2B 4C 6D 8