ADDREV

ADDREV

#include<iostream>

int reverse(int a)
{
       int b[10000];int j=0;
    int term=0,rev=0;
    int multi;
    while(a>0)
    {
             
              b[j]=a%10;
              j++;
              a=a/10;
              }
              for(int x=j;x>0;x--)
              {
                  multi=1;
                  for(int y=0;y<(x-1);y++)
                  multi=multi*10;
                  term=b[j-x]*multi;   
                      rev=rev+term;
                      }
    return rev;
    }


using namespace std;

int main()

{
int a,b,c;
int rev1,rev2,rev3,sum;
cin>>a;
for(int i=0;i<a;i++)
{
cin>>b>>c;
rev1=reverse(b);
rev2=reverse(c);
sum=rev1+rev2;
rev3=reverse(sum);
cout<<rev3<<endl;
}

return 0;

}

No comments:

Post a Comment