题解 | #Integer Inquiry#
Integer Inquiry
https://www.nowcoder.com/practice/df03906024d742cc919a64c22983f5e1
import java.util.Scanner;
import java.math.BigInteger;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// ArrayList<BigInteger> list = new ArrayList<BigInteger>;
BigInteger b = BigInteger.valueOf(0);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextBigInteger()) { // 注意 while 处理多个 case
BigInteger a = in.nextBigInteger();
if(a.equals(BigInteger.valueOf(0)))break;
b = b.add(a);
}
System.out.println(b);
}
}
真是jaja又vava啊
