纵然c++大数操作可以转化成字符创高精度,但对于刚入门的同学来说,Java的大数类完全可以完成基本运算—不过脑的运算。
import java.math.BigInteger;
import java.util.Scanner;
public class WQ {
public static void main(String[] args)
{
BigInteger m1,m2,m3,m4,m5;
Scanner a = new Scanner(System.in);
int t=a.nextInt();
while(t != 0)
{
m1 = a.nextBigInteger();
m2 = a.nextBigInteger();
m3 = a.nextBigInteger();
m4 = a.nextBigInteger();
m5 = m1.add(m2);
m5 = m5.add(m3);
m5 = m5.add(m4);
System.out.println(m5);
t--;
}
}
}