首页 > 其他 > 详细

高精度练习

时间:2020-07-19 11:57:54      阅读:28      评论:0      收藏:0      [点我收藏+]

 

package Deom1;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.SortedMap;
//加法练习
public class lx {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
String str = sc.next();
BigInteger b = new BigInteger(s);  //BigInteger继承自Number类,可表示任意长度的整数。BigInteger用等号可以直接进行复制,而不是引用地址
BigInteger big = new BigInteger(str);
System.out.println(b.add(big));
}
}

package Deom1;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.SortedMap;
//乘法练习
public class lx {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
BigInteger a = sc.nextBigInteger();
BigInteger b = sc.nextBigInteger();
BigInteger c = a.multiply(b);
System.out.println(c);
}
}


高精度练习

原文:https://www.cnblogs.com/lixiang0622/p/13338547.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!