Java中String类与Integer类的几个方法
时间:2014-05-03 16:50:55
收藏:0
阅读:307
计算诸如-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)); } } }
评论(0)