题目内容 (请给出正确答案)
[主观题]

有以下面程序: include <iostream> 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));

else

return 2;

}

int main()

{

cout<<fib(3)<<endl;

return 0;

}

则该程序的输出结果应该是【 】。

提问人:网友cole555 发布时间:2022-01-06
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“有以下面程序: include <iostream> usi…”相关的问题
第1题
对于代码片段: #include ...

对于代码片段: #include <fstream> #include <iostream> using namespace std; int main(){ fstream binaryio; // Create stream object // Read array from the file binaryio.open("array.dat", ios::in | ios::binary); char result[10] = {'\0'}; binaryio.read(reinterpret_cast <char *> (result), 20); cout << result; return 0; } 其中array.dat文件中存放的内容以字节序列表示,各字节的值为 0x30, 0x31, ..., 0x60 执行之后可能出现的状况有:

A、屏幕上没有输出,程序结束,未报告错误

B、屏幕上输出了10个以上字符,程序结束,未报告错误

C、屏幕上输出了10个以上字符,程序出错

D、屏幕上输出了9个字符,然后程序报错

点击查看答案
第2题
下面程序的输出是:***********5.235.23*********** 请将下划线上遗漏的部分补充完整。include<ios

下面程序的输出是:

***********5.23

5.23***********

请将下划线上遗漏的部分补充完整。

include <iostream>

include <iomanip>

using namespace std:

void main(){

double i=5.23;

cout<<______<<setw(14)<<i

couu<<end1<<______<<setw(14)<<i;

}

点击查看答案
第3题
下面程序的预设功能是:统计文件abc.txt中的字符个数。 include <iostream.h> include <fstream.h>

下面程序的预设功能是:统计文件abc.txt中的字符个数。

include <iostream.h>

include <fstream.h>

include <stdlib.h>

void main()

{

fstream file;

file.open("abc.txt", ios::in);

if (!file )

{

cout<<"Can not open abc.txt"<<end1;

abort();

}

char ch;

int i = O;

while (______________)

{

file.get(ch);

i++;

}

cout<<"Characters : "<<i<<end1;

file.close();

}

则程序中空白处应该填入的语句是【 】。

点击查看答案
第4题
有以下程序:#include<iostream.h>#include<iomanip.h>void main(){cout.fill('*');cout.width(10

有以下程序: #include<iostream.h> #include<iomanip.h> void main() { cout.fill('*'); cout.width(10); cout,<setiosflags(ios::left)<<123.45<<endl; } 程序执行后的输出结果是()

A.****123.45

B.**123.45**

C.123.45****

D.***123.45*

点击查看答案
第5题
有以下程序: include<iostream.h> include<fstream.h> include<stdlib.h> intmain() {fstreamfil

有以下程序:

include <iostream.h>

include <fstream.h>

include <stdlib.h>

int main()

{

fstream filel,file2;

char line[100];

filel.open("source.txt",ios::in);

if(!file1)

{

cout<<"Can't open file source.txt!"<<end1;

abort();

}

file2.open("dest.txt",ios::out);

if(!file2)

{

cout<<"Can't open file dest.txt!"<<end1;

abort();

}

while(!file1.eof())

{

filel.getline(1ine,100);

file2<<line;

file2<<end1;

}

filel.close();

file2.close();

return 0;

}

此程序实现的功能是【 】。

点击查看答案
第6题
有以下程序:include<iostream>include<fstream>using namespace std;int main(){fstream file;fi

有以下程序:

include<iostream>

include<fstream>

using namespace std;

int main()

{

fstream file;

file.open("abc.txt", ios :: in);

if (!file )

{

cout<<"Can not open abc.txt"<<end1;

abort();

}

char buf[ 80 ];

int i = 0;

while (!file.eof())

{

file.getline(buf,80);

i++;

}

cout<<"Lines :"<<i<<end1;

file.close();

return 0;

}

程序实现的功能是【 】。

点击查看答案
第7题
以下程序的执行结果是_______。 include<iostream.h> include<fstream.h> include<stdlib.h> void

以下程序的执行结果是_______。

include<iostream.h>

include<fstream.h>

include<stdlib.h>

void main()

{

char ch:

fstream file:

file.open("abc.dat",ios::out1ios::inlios::binary);

if(! file)

{

cout<<“abc.dat文件不能打开”<<endl:

abort

点击查看答案
第8题
文本文件letters.txt中已经存有“abcdefg”七个字符,则...

文本文件letters.txt中已经存有“abcdefg”七个字符,则下列程序的运行结果是 。 #include <fstream.h> #include <stdlib.h> void main(void) { fstream file("letters.txt",ios::in); char ch; if (!file) exit(0); file.seekg (2L, ios::beg); file.get(ch); cout << ch ; file.seekg (-3L, ios::end); file.get(ch); cout << ch ; file.seekg (1L, ios::cur); file.get(ch); cout << ch << endl; file.close(); }

点击查看答案
第9题
假设文本文件letters.txt中已经存有“1234567890”十个...

假设文本文件letters.txt中已经存有“1234567890”十个字符,则下列程序的运行结果是 。 #include <fstream.h> #include <stdlib.h> void main(void) { fstream file("nums.txt",ios::in); char ch; if (!file) exit(0); file.seekg (1L, ios::beg); file.get(ch); cout << ch << endl; file.seekg (-5L, ios::end); file.get(ch); cout << ch << endl; file.seekg (-2L, ios::cur); file.get(ch); cout << ch << endl; file.close(); }

点击查看答案
第10题
简要叙述下列程序代码,并判断如下程序的功能: #includ...

简要叙述下列程序代码,并判断如下程序的功能: #include <fstream> #include <iostream> using namespace std; int main(int argc, char* argv[]) { char c; fstream fio(argv[1], ios::in | ios::out); if (fio.fail()) //打开文件成功与否监控 { cerr << "Cannot open file:" << argv[1] << endl; return 1; } while((c=fio.get())!=EOF) //判断是否到达文件末尾 if (isupper(c)) { fio.seekg(-1, ios::cur); fio.put(tolower(c)); } fio.close(); return 0; }

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信