题解 | #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啊

全部评论

相关推荐

迷茫的大四🐶:看来已经准备换人了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-19 18:52
七牛云一生之敌I两个...:自我评价删了,其他浓缩为一页
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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