这个题目是大数相加 ,采用java的BigInteger很好解决,注意空行的打印要求
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
//大数相加
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n=scanner.nextInt();
String a,b;
for(int i=1;i<=n;i++){
a=scanner.next();
b=scanner.next();
System.out.println("Case "+i+":");
System.out.println(a+" + "+b+" = "+add(a, b));
if(i!=n){
System.out.println();
}
}
}
public static String add(String a,String b){
BigInteger aBigInteger=new BigInteger(a);
BigInteger bigInteger=new BigInteger(b);
return aBigInteger.add(bigInteger).toString();
}
}