HDU 1000 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
 
 
题意:输入两个数,求输入的两个数之和。
分析:注意题目暗含循环输入输出。
AC源代码(C语言):
#include <stdio.h>

int main()
{
int a, b;
while(scanf("%d%d", &a, &b) != EOF)
{
printf("%d\n", a+b);
}
return 0;
}

 

Java语言:
import java.util.Scanner;


public class Main {
public static void main(String[] args) {
int a, b;
Scanner sin = new Scanner(System.in);
while(sin.hasNextInt()){
a = sin.nextInt();
b = sin.nextInt();
System.out.println(a+b);
}
}
}

 

posted @ 2017-05-08 17:18  世界和“你”  阅读(264)  评论(0编辑  收藏  举报