就是简单的整数相加,当没有输入的时候退出。
很早以前就是通过这题知道了用scanf()!=EOF来检验是否还有输入
#include <cstdio>
using namespace std;
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF){
printf("%d\n",a+b);
}
return 0;
}
本文介绍了一个基本的编程问题:通过使用scanf()函数和EOF标志来实现整数相加并判断输入是否结束的功能。这是一个入门级的C语言编程实例,适合初学者了解如何进行基本的输入输出操作。
就是简单的整数相加,当没有输入的时候退出。
很早以前就是通过这题知道了用scanf()!=EOF来检验是否还有输入
#include <cstdio>
using namespace std;
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF){
printf("%d\n",a+b);
}
return 0;
} 
被折叠的 条评论
为什么被折叠?