题目简单,仅作记录用
------------------------------------------------------------------------------------------------------import java.util.Scanner;
public class hdoj1000 {
public static void main(String[] args){
String a = null;
String b = null;
int case_num;
Scanner in = new Scanner(System.in);
case_num = in.nextInt();
for (int x = 0; x < case_num; x++)
{
a = in.next();
b = in.next();
int flag = 0;
char[] as = new char[1000];
char[] bs = new char[1000];
char[] is = new char[1001];
int max = a.length() > b.length() ? a.length() : b.length();
for (int i = 0; i < a.length(); i++) as[i] = a.charAt(a.length()-1 - i);
for (int i = 0; i < b.length(); i++) bs[i] = b.charAt(b.length() -1 - i);
for (int i = 0; i < max; i++)
{
if(as[i] == 0)
is[i] = bs[i];
else if(bs[i] == 0)
is[i] = as[i];
else {
is[i] = (char) (as[i] + bs[i]);
is[i] = (char) (is[i] - '0');
}
}
for (int i = 0; i < max ; i++)
{
if(i == max - 1 && is[i] > '9')
flag = 1;
if(is[i] > '9')
{
is[i] = (char) (is[i] - 10);
is[i + 1] = (char) (is[i + 1] + 1);
}
}
if (flag == 1) {
is[max] = '1';
String s = "";
for(int i = 0; i <= max; i++)
{
s += is[max - i];
}
int tmp = x + 1;
System.out.println("Case " + tmp + ":");
System.out.println(a + " + " + b + " = " + s );
}else
{
String s = "";
for (int i = 0; i < max; i++) s += is[max - i - 1];
int tmp = x + 1;
System.out.println("Case " + tmp + ":");
System.out.println(a + " + " + b + " = " + s );
}
if(x != case_num - 1)
System.out.println();
}
}
}