码迷,mamicode.com
首页 > 其他好文 > 详细

ACM HDU 1000

时间:2017-09-20 23:20:22      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:acm   author   desc   判断   integer   tput   成功   tle   for   

A + B Problem

 

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
 
Author
HDOJ
 
 
解题思路:非常简单的一道水题,输入两个整数,输出整数的和。
代码如下 (C语言)
#include <stdio.h>
int main(void)
{
    int a, b;
    int sum,ch;
    while ((ch = scanf_s("%d %d", &a, &b)) == 2)
    {
        sum = a + b;
        printf("%d\n", sum);
    }
    
    return 0;
}
本来以为需要EOF判断结束的,没想到这样成功了。还是不明白AC的机制。

ACM HDU 1000

标签:acm   author   desc   判断   integer   tput   成功   tle   for   

原文地址:http://www.cnblogs.com/WLHBlog/p/7565247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!