#include<stdio.h>
#include<string.h>
int main()
{
char a[210], b[210];
int i, j, k, n, m, x, y;
scanf("%d", &x);
while(x--)
{
int s[210] = {0};
scanf("%s %s", a, b);
n = strlen(a);
m = strlen(b);
k = n>m ? n : m;
for(i=0;i<n;i++)
{
s[i] = s[i] + (a[i] - 48);
}
for(i=0;i<m;i++)
{
s[i] = s[i] + (b[i] - 48);
}
for(i=0;i<k+1;i++)
{
if(s[i]>=10)
{
s[i+1] = s[i+1] + s[i]/10;
s[i] = s[i]%10;
}
}
for(j=k+1;j>=0;j--)
{
if(s[j] != 0)
{
break;
}
}
if(j<0)
{
j++;
}
i = 0;
while(s[i] == 0)
{
i++;
}
while(i<=j)
{
printf("%d", s[i]);
i++;
}
printf("\n");
}
return 0;
}
#include<string.h>
int main()
{
char a[210], b[210];
int i, j, k, n, m, x, y;
scanf("%d", &x);
while(x--)
{
int s[210] = {0};
scanf("%s %s", a, b);
n = strlen(a);
m = strlen(b);
k = n>m ? n : m;
for(i=0;i<n;i++)
{
s[i] = s[i] + (a[i] - 48);
}
for(i=0;i<m;i++)
{
s[i] = s[i] + (b[i] - 48);
}
for(i=0;i<k+1;i++)
{
if(s[i]>=10)
{
s[i+1] = s[i+1] + s[i]/10;
s[i] = s[i]%10;
}
}
for(j=k+1;j>=0;j--)
{
if(s[j] != 0)
{
break;
}
}
if(j<0)
{
j++;
}
i = 0;
while(s[i] == 0)
{
i++;
}
while(i<=j)
{
printf("%d", s[i]);
i++;
}
printf("\n");
}
return 0;
}
Comments
Post a Comment