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)

全部评论

相关推荐

这算盘打的
程序员小白条:都这样的,都是潜规则,你自己说可以实习一年就行了,实习可以随便跑路的
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务