package test;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = 1;
String string1,string2;
char[] chars1,chars2;
int n = sc.nextInt();
while(sc.hasNextInt()){
string1 = sc.nextInt()+"";
string2 = sc.nextInt()+"";
chars1 = string1.toCharArray();
chars2 = string2.toCharArray();
int end1 = chars1.length-1;
int end2 = chars2.length-1;
int flag = 0;
StringBuilder sb = new StringBuilder();
while(end1>=0 || end2>=0){
int sum = flag;
if(end1>=0) sum+=chars1[end1]-'0';
if(end2>=0) sum+=chars2[end2]-'0';
if(sum>=10){
sb.insert(0, sum%10);
flag = 1;
}else{
sb.insert(0, sum);
flag = 0;
}
end1--;end2--;
}
if(flag==1) sb.insert(0, 1);
System.out.println("Case "+i+":");
System.out.println(string1+" + "+string2+" = "+sb.toString());
if(i!=n)
System.out.println();
i++;
}
}
}
A + B Problem II (1002)
最新推荐文章于 2021-01-30 13:04:09 发布