题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047
简单的大数相加问题
源代码:
import java.math.BigInteger;
import java.util.Scanner;
//78MS 2976K AC
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
BigInteger sum ;
for (int i = 1; i <= t; i++) {
sum = BigInteger.ZERO;
while (true) {
BigInteger num = scanner.nextBigInteger();
if (num.equals(BigInteger.ZERO)) {
break;
} else {
sum = sum.add(num);
}
}
System.out.println(sum);
if (i != t) {
System.out.println();
}
}
}
}