/*
问题描述
输入两个正整数a,b,输出a+b的值。
输入格式
两行,第一行a,第二行b。a和b的长度均小于1000位。
输出格式
一行,a+b的值。
样例输入
4
2
样例输出
6
*/
#include<stdio.h>
void shuru( int [] , int *);
void q_nx( int [] , int );
void shuchu( int [] , int);
void q_he(int [] , int , int [] , int , int [] , int * );
void put_in(int [] , int [] , int [] , int );
int main( void )
{
int s1[1000]={0} ,s2[1000]={0} ,c[1001]={0};
int cd1=0,cd2=0;
shuru(s1 , &cd1 );
shuru(s2 , &cd2 );
int ws=0;
q_he(s1 , cd1 , s2 , cd2 , c , &ws);
shuchu( c , ws);
return 0;
}
void put_in(int s1[] , int s2[] , int c[] , int cd )
{
int i;
for(i = 0 ; i < cd ; i ++)
{
c[i]=s1[i]+s2[i];
}
}
void q_he(int s1[] , int cd1, int s2[] , int cd2, int c[] , int * ws)
{
int n=cd1 > cd2 ? cd1 : cd2;
put_in( s1 , s2 , c , n);
int i;
for(i = 0 ; i < n ; i ++)
{
c[i+1] += c[i]/10;
c[i] %= 10;
++ *ws;
}
if(c[n] > 0)
{
++ *ws;
}
}
void shuchu( int sz[] , int n)
{
int i;
for( i = n-1 ; i >=0 ; i--)
{
printf("%d",sz[i]);
}
}
void q_nx( int sz[] , int n)
{
int tou=0,wei = n -1;
while(tou < wei)
{
int tmp=sz[tou];
sz[tou]=sz[wei];
sz[wei]=tmp;
tou++;
wei--;
}
}
void shuru( int sz[] , int * cd)
{
char c;
while((c = getchar()) !='\n' )
{
sz[*cd] = c -'0';
++ *cd ;
}
q_nx( sz , * cd );
}