题解 | 多组_A+B_EOF形式
多组_A+B_EOF形式
https://www.nowcoder.com/practice/295063bf1bce4c2e819a8f18a5efcd20
#include <iostream>
using namespace std;
int main() {
    int a, b;
    while (cin >> a >> b) { // 注意 while 处理多个 case
        cout << a + b << endl;
    }
}
std::cin 遇到空格、回车、Tab 会停止读取。
cin >> a >> b 是一个输入流操作,会将用户输入的内容依次提取到变量 a 和 b 中。
如果输入有效的数字,cin 会成功读取,然后返回 true 。
用户输入的不是有效的数字,或者输入结束(如文件结尾或错误),cin 会设置输入流的错误标志,然后返回 false 。
 投递深信服等公司10个岗位
投递深信服等公司10个岗位