#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define M 1005
char a[M], b[M];
void add(char a[], char b[])
{
int i, j;
int a1[M] = { 0 }, b1[M] = { 0 };
int l1 = strlen(a), l2 = strlen(b);
for (i = l1 - 1, j = 0; i >= 0; i--, j++) a1[j] = a[i] - '0';
for (i = l2 - 1, j = 0; i >= 0; i--, j++) b1[j] = b[i] - '0';
for (i = 0; i <= 1001; i++)
{
a1[i] += b1[i];
if (a1[i] >= 10)
{
a1[i] -= 10;
a1[i +1]++;
}
}
for (i = 1001; i >= 0 && a1[i] == 0; i--); //排空无关零
for (; i >= 0; i--) cout << a1[i];
}
int main()
{
int t;
cin >> t;
for (int i = 1; i <= t; i++)
{
cin >> a >> b;
cout << "Case " << i << ":" << endl;
cout << a << " + " << b << " = ";
add(a, b);
cout << endl;
if (i != t) cout << endl;
}
return 0;
}
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define M 1005
char a[M], b[M];
void add(char a[], char b[])
{
int i, j;
int a1[M] = { 0 }, b1[M] = { 0 };
int l1 = strlen(a), l2 = strlen(b);
for (i = l1 - 1, j = 0; i >= 0; i--, j++) a1[j] = a[i] - '0';
for (i = l2 - 1, j = 0; i >= 0; i--, j++) b1[j] = b[i] - '0';
for (i = 0; i <= 1001; i++)
{
a1[i] += b1[i];
if (a1[i] >= 10)
{
a1[i] -= 10;
a1[i +1]++;
}
}
for (i = 1001; i >= 0 && a1[i] == 0; i--); //排空无关零
for (; i >= 0; i--) cout << a1[i];
}
int main()
{
int t;
cin >> t;
for (int i = 1; i <= t; i++)
{
cin >> a >> b;
cout << "Case " << i << ":" << endl;
cout << a << " + " << b << " = ";
add(a, b);
cout << endl;
if (i != t) cout << endl;
}
return 0;
}