解题思路:
注意事项:
参考代码:
#include
#include
int main(void)
{
char a[103], b[103];
int lengtha, lengthb;
while (scanf("%s%s", a, b) != EOF)
{
int num1[103] = { 0 }, num2[103] = { 0 }, num3[103] = { 0 }, i, j, l;
lengtha = strlen(a);
lengthb = strlen(b);
for (i = 0;i <= lengtha - 1;i++)
num1[i] = a[lengtha - 1 - i] - '0';
for (j = 0;j <= lengthb - 1;j++)
num2[j] = b[lengthb - 1 - j] - '0';
if (lengtha > lengthb)
{
int c = 0, num;
for (l = 0;l <= 100;l++)
{
num = num1[l] + num2[l] + c;
if (num >= 10)
{
num3[l] = num % 10;
c = num / 10;
}
else
{
num3[l] = num;
c = 0;
}
}
}
else
{
int c = 0, num;
for (l = 0;l <= 100;l++)
{
num = num1[l] + num2[l] + c;
if (num >= 10)
{
num3[l] = num % 10;
c = num / 10;
}
else
{
num3[l] = num;
c = 0;
}
}
}
l = 100;
while (num3[l] == 0)
l--;
for (i = l;i >= 0;i--)
printf("%d", num3[i]);
printf("\n");
}
return 0;
}