import java.util.Scanner;
import java.math.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s1 = sc.next();
String s2 = sc.next();
BigInteger a2 = new BigInteger(s1);
BigInteger b2 = new BigInteger(s2);
BigInteger result1=a2.add(b2); //加法
BigInteger result2 = a2.mod(b2); //a2 mod b2取餘
BigInteger result3 = a2.multiply(b2); //乘法
BigInteger result4 = a2.divide(b2); //除法 a2/b2 b2 = 0.會終止程序,拋出異常
BigInteger result5 = a2.subtract(b2); //減法。a2 - b2.+
System.out.println (result1 );
System.out.println (result2 );
System.out.println (result3 );
System.out.println (result4 );
System.out.println (result5 );
}
}
利用java 快速實現加減乘數餘運算
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.