Your task is to Calculate a + b.
Too easy?! Of course! I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim
Input
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
Sample Input
1 5 10 20
Sample Output
6 30
Hint
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while(in.hasNext())
{int a,b;
a=in.nextInt();
b=in.nextInt();
System.out.println(a+b);
}
}
}
本文介绍了一个简单的Java程序,用于解决计算两个整数a和b之和的问题。该程序适用于初学者,通过读取标准输入的一系列整数对,并输出每对整数的和。代码示例展示了如何使用Java的Scanner类从输入流中读取数据。
1469

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



