遇到高精度怎么办?用几十行的C/CPP!?显然不是最佳选择。
此时用JAVA就能轻松解决:
import java.math.BigDecimal;import java.util.Scanner;import java.math.BigInteger; public class Main{ public static void main(String args[]){ BigInteger a[] = new BigInteger[110]; BigInteger b[] = new BigInteger[110]; Scanner cin = new Scanner(System.in); int n; n = cin.nextInt(); for (int i=1;i<=n;i++) { a[i] = cin.nextBigInteger(); b[i] = cin.nextBigInteger(); System.out.println(a[i].add(b[i])); System.out.println(a[i].subtract(b[i]); } }}