已知递归函数f的定义如下: int f(int n) { if(n <=1)return 1; //递归结束情况 else return n*f(
已知递归函数f的定义如下:
int f(int n)
{
if(n <=1)return 1; //递归结束情况
else return n*f(n-2); //递归}
则函数调用语句f(5)的返回值是【 】。
已知递归函数f的定义如下:
int f(int n)
{
if(n <=1)return 1; //递归结束情况
else return n*f(n-2); //递归}
则函数调用语句f(5)的返回值是【 】。
第1题
下列程序的运行结果是______。
include<iomanip.h>
int Func(int *a,int n)
{int s=1;
for(int i=0;i<n;i++)
s*=*a++;
returns;}
void main()
{inta[]:{1,2,3,4,5,6,7,8};
intb=Func(a,6)+Func(&a[5],2);
cout<<“b=“<(b<<endl;}
第3题
下列程序段的输出结果是_____。
cout < < fixed < < 509.123456789 < < endl;
第6题
下面程序的输出结果是______。
include<iostream.h>
void main()
{
inta[6]={1,2,3,4,5,6};
for(int i=0;i<5;i++)
cout<<a[i]<<““;
cout<<endl;
第7题
下面程序的结果为______。
include<iostream.h>
void main()
{
int 3=1,b=2;
bool c=1;
if(a>b)||c)cout<<“true”<<endl;
else
cout<<“false”<<endl;
}
第9题
有以下程序
include<iostream>
using namespace std;
long fib(int n)
{
if(n>2)
return(fib(n-1)+fib(n-2));
else
return 2;
}
int main( )
{
cout<<fib(3)<<endl;
return 0;
}
则该程序的输出结果应该是______。
第10题
的输出结果为:After Sorting:Happy Welcome,请将程序补充完整。
include<iostream>
include<string>
using namespace std;
class Word{
public:
Word(string s):str(s){}
string getStr(){retum str;}
【 】const{retum(str<w.str);}
friend ostream&operator<<(ostream&output,const W0rd&w)
{output<<w.str;return output;}
private:
string str:
};
int main(){
Word wl(”Happy”),w2(“Welcome”);
eout<<”After sorting:”:
if(w1<w2)tout<<wl<<‘ ’<<w2:
else cout<<w2<<‘ ’<<wl:
return 0;
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!