N. [GESP]L4-202409-Q2620-S
[GESP]L4-202409-Q2620-S
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
小杨用文件重定向实现在 log.txt 文件中输出日志,则下面横线上应填写( )。
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ofstream log_file("log.txt");
streambuf* original_cout = cout.rdbuf();
cout.rdbuf(log_file.rdbuf());
// 在此处填入代码
cout.rdbuf(original_cout); // 恢复原始的标准输出缓冲区
return 0;
}
{{ select(1) }}
cout << "This output will go to the log file." << endl;log_file << "This output will go to the log file." << endl;cout >> "This output will go to the log file." >> endl;log_file >> "This output will go to the log file." >> endl;
GESP 2024.09 C++ 四级 全真模拟赛
- 状态
- 已结束
- 规则
- OI
- 题目
- 27
- 开始于
- 2026-11-20 13:30
- 结束于
- 2026-11-25 13:30
- 持续时间
- 2 小时
- 主持人
- 参赛人数
- 0