高精度练习
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);
}
}