HDU

来源:互联网 发布:蛤文化知乎 编辑:程序博客网 时间:2024/06/03 15:08

练习 JAVA 

最水的 A+B problem ,,当时用 c 写的时候,手动字符串模拟的大整数想加

有了 JAVA 的大整数类,就很简单了


//package first;import java.math.*;import java.util.*;public class Main {public static BigInteger Sum(BigInteger a, BigInteger b) {BigInteger c;c = a.add(b);return c;}public static void main(String[] args) {Scanner in = new Scanner(System.in);int T;BigInteger a, b;T = in.nextInt();for(int i = 1; i <= T; ++i) {a = in.nextBigInteger();b = in.nextBigInteger();System.out.println("Case "+i+":");System.out.println(a + " + " + b + " = " + Sum(a, b)); if(i < T) System.out.println();}}}


原创粉丝点击