#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
cout<<a+b<<endl;
}
return 0;
}
注意 cin>>a>>b 当遇见end of file时 会返回false
本文介绍了一个简单的C++程序,该程序使用标准输入输出库来实现两个整数的加法运算,并通过循环读取用户输入直到文件结束。文章还解释了如何处理文件结束时的输入状态。
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
cout<<a+b<<endl;
}
return 0;
}
注意 cin>>a>>b 当遇见end of file时 会返回false

被折叠的 条评论
为什么被折叠?