# include <stdio.h>
# include <stdlib.h>
int main(void)
{
char * s = (char *)malloc(200 * sizeof(char));
int * h = (int *)malloc(100 * sizeof(int));
int * m = (int *)malloc(100 * sizeof(int));
int n[110] = {0};
int i, j, t, x, q;
printf("请输入需要计算的题目:\n");
scanf("%s", s);
for (x=0, i=0; *(s+x); x++, i++)
{
if (*(s+x) >= '0' && *(s+x) <= '9')
h[i] = (*(s+x) - 48);
else
break;
}
if (*(s+x) == '+')
x ++;
for (j=0; *(s+x); x++, j++)
{
if (*(s+x) >= '0' && *(s+x) <= '9')
m[j] = (*(s+x) - 48);
else
break;
}
free(s);
if (i > j)
q = t = i;
else
q = t = j;
while (t >= 0 && i >=0 && j >=0)
{
n[t] = n[t] + h[i] + m[j];
if (t == 0)
break;
if (n[t] >= 10)
{
n[t] = n[t] - 10;
n[t-1] ++;
}
t --;
i --;
j --;
}
while (t >= 0)
{
if (i < 0)
n[t] = n[t] + m[j];
if (j < 0)
n[t] = n[t] + h[i];
t --;
i --;
j --;
}
free(h);
free(m);
for (i=0; i<q; i++)
printf("%d", n[i]);
printf("\n");
return 0;
}