计算诸如-123,456,789 + 123,123的值
import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); String str1, str2; BigInteger a, b; while(cin.hasNext()){ str1 = cin.next(); str2 = cin.next(); str1 = str1.replaceAll(",", ""); str2 = str2.replaceAll(",", ""); a = new BigInteger(str1); b = new BigInteger(str2); System.out.println(a.add(b)); } } }
Java中String类与Integer类的几个方法
时间: 2024-10-27 07:54:35