本文共 497 字,大约阅读时间需要 1 分钟。
题目链接:
解题思路一:使用BigInteger类
解题思路二:字符串拆分处理
//思路一代码import java.util.*;import java.math.BigInteger;public class Main1{ public static void main(String[] args){ Scanner input=new Scanner(System.in); while(input.hasNext()){ String s1=input.next(); String s2=input.next(); BigInteger num1=new BigInteger(s1);//采用BigInteger可以直接进行大整数进行计算 BigInteger num2=new BigInteger(s2); System.out.println(num1.add(num2)); } }}
转载地址:http://vejwi.baihongyu.com/