**
-
如 78789890000000098978加5647638738398; 》方法
先都倒过来数对位相加,进位保留十位数,不进化为0;最后再将得数倒回来即可;(有可能两数位数不等就要加到位数少的,在单独存较多位的数;!!!进阶很需要思考!!!)**#include<stdio.h>
#include<string.h>
char a[1000];
char b[1000];
char c[1001];
void fun(char a[], int n)
{
int i, t = 0;
char c;
n = n-1;
for (i = n, t; i > t; i–, t++)
{
c = a[i];
a[i] = a[t];
a[t] = c;
}
}
int main()
{
int s1, s2, s3, max, z, t, i = 0, x, y;
gets_s(a);
gets_s(b);
s1 = strlen(a);
s2 = strlen(b);
fun(a, s1);倒过来数
fun(b, s2);倒过来数
if (s1 > s2)
max = s1;
else
max = s2;
z = 0;
do
{
x = a[i] - ‘0’;
y = b[i] - ‘0’;
z = z + x + y;
if (z >= 10)
{
t = z % 10;
z = z / 10;
c[i] = t + ‘0’;
}
else if (z<10)
{
c[i] = z + ‘0’;
z = 0;
}
i++;
} while (i<s1&&i<s2);
//两数位数不等
if (i != max)
{
if (s1 > s2)
{
do
{
x = a[i] - ‘0’;
z = z + x;
if (z >= 10)
{z = z % 10;
t = z / 10;
c[i] = z + ‘0’;
}
else if (z < 10)
{
c[i] = z + ‘0’;
z = 0;
}
i++;
} while (i != max);
}
if (s2 > s1)
{
do
{
x = b[i] - ‘0’;
z = z + x;
if (z >= 10)
{
t = z / 10;
z = z % 10;
c[i] = z + ‘0’;
}
else if (z < 10)
{
c[i] = z + ‘0’;
z = 0;
}
i++;
} while (i != max);
}
}
if (z != 0)
{
c[i] = z+‘0’;
c[i + 1] = ‘\0’;
}
else
c[i] = ‘\0’;
s3 = strlen©;
fun(c, s3);数倒回来
puts©;
return 0;
}