杭电acm刷题记录ID1000

来源:互联网 发布:淘宝客采集软件多少钱 编辑:程序博客网 时间:2024/06/05 10:16
Problem Description
Calculate A + B.
Input
Each line will contain two integers A and B. Process to end of file.
Output
For each case, output A + B in one line.
Sample Input
1 1
Sample Output
2
这本是个非常简单的问题,骚就骚在end of file。看到这里当时我就慌了,难道还要用文件输入输出?这样的话,文件名是什么?无奈之下上网百度,得到如下处理方式
while(scanf("%d%d",&a,&b) != EOF)
其实就是把输入缓冲区的东西全读出来……什么end of file,搞事情!
答案代码
#include <stdio.h>int main(void){    int a,b;    while(scanf("%d%d",&a,&b)!=EOF)        printf("%d\n",a+b);    return 0;}


原创粉丝点击