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.
简单的说下
作为初学者刚开始做的一题,只要明白此题不是只计算一次就好,对于每次输入都有输出来,因此不能再计算一次后就结束。在hdu中,要提交时要把文件名改成Main,否则编译会通不过。
代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a+b);
}
}
}
这是一篇关于如何解决编程问题的博客,主要讲解如何通过编程实现将两个整数相加并输出结果。适用于初学者,强调了多次输入与输出的概念,并提供了使用Java语言的示例代码。
396

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



