C++真是太难用了,还是Java和Python好用。
Integer Inquiry
https://www.nowcoder.com/practice/df03906024d742cc919a64c22983f5e1
//Java版代码 import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger sum = BigInteger.ZERO; BigInteger a; do { a = sc.nextBigInteger(); sum = sum.add(a); } while (!a.equals(BigInteger.ZERO)); System.out.println(sum); } } #Python版代码 a = int(input()) sum = a while a: a = int(input()) sum += a print(sum)