← 返回题目列表

AtCoder · APG4b_cu

EX2. 第1.02节

中文机器翻译题面 查看原题

返回说明页面

在解决问题之前 附录2.提交结果的查看方法请阅读。


問題文

A君尝试制作会产生如下输出的程序。

実行結果
いつも2525
AtCoderくん

但是,当尝试执行编写的程序时发生了错误。
请修复A君写的程序的错误,使其能够正确运行。

A君写的程序
#include <bits/stdc++.h>
using namespace std;

int main() {
  cout << "いつも << 252 << endl;
  cout << "AtCoderくん" << endl
}

如果在代码测试中运行此代码,将在标准错误输出中显示以下错误消息。

标准错误输出
./Main.cpp:5:11: warning: missing terminating " character
   cout << "いつも << 252 << endl;
           ^
./Main.cpp:5:3: error: missing terminating " character
   cout << "いつも << 252 << endl;
   ^
./Main.cpp:6:3: error: stray ‘\343’ in program
   cout << "AtCoderくん" << endl
   ^
./Main.cpp:6:3: error: stray ‘\200’ in program
./Main.cpp:6:3: error: stray ‘\200’ in program
./Main.cpp: In function ‘int main()’:
./Main.cpp:5:8: error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘std::ostream {aka std::basic_ostream<char>}’)
   cout << "いつも << 252 << endl;
        ^
./Main.cpp:5:8: note: candidate: operator<<(int, int) <built-in>
./Main.cpp:5:8: note:   no known conversion for argument 2 from ‘std::ostream {aka std::basic_ostream<char>}’ to ‘int’
In file included from /usr/include/c++/5/istream:39:0,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
    ...

处理这个问题的方法

A君的程序包含多个错误。
请从能理解的错误开始,一次修复一个,在代码测试中进行运行,并确认是否已经修复。

代码测试的使用方法见附录1. 代码测试的使用方法中有说明。

注意“AtCoder”的“C”是大写。

提示

1.02.程序的写法与错误请参考“编译错误的例子”。


解答例

一定要自己尝试解决问题后再看。

点击查看答案例

#include <bits/stdc++.h>
using namespace std;

int main() {
  cout << "いつも" << 2525 << endl;
  cout << "AtCoderくん" << endl;
}