#include<bits/stdc++.h>
using namespace std;
void revsu(string &,string &);
void fuglo(string &,int);
int main()
{
string a,b;
int N;
cin>>N;
if(N>=1&&N<=10000)
while(N–)
{
cin>>a>>b;
reverse(a.begin(),a.end());
reverse(b.begin(),b.end());
// cout<<"\n";
revsu(a,b);
cout<<"\n";
}
return 0;
}
void revsu(string &a,string &b)
{
string p(‘0’,0);
int g,t,m,n,s=0,k=0,i,j,car=0;
m=a.size();
n=b.size();
k=m>n?m+1:n+1;
t=k;
p.resize(k);
p[k]=’\0’;
i=m-1;
j=n-1;
if(m>n)
{
while(i>=0&&j>=0)
{
k–;
s=(a[i]-‘0’)+(b[j]-‘0’)+car;
p[k]=(s%10)+48;
car=s/10;
i–;
j–;
//cout<<p[k];
}
while(i>=0)
{
k–;
s=(a[i]-‘0’)+car;
p[k]=(s%10)+48;
car=s/10;
i–;
//cout<<p[k];
}
if(car>0)
{
k–;
p[k]=‘1’;
//cout<<p[k];
}
}
else
{
while(i>=0&&j>=0)
{
k–;
s=(a[i]-‘0’)+(b[j]-‘0’)+car;
p[k]=(s%10)+48;
car=s/10;
i–;
j–;
//cout<<p[k];
}
while(j>=0)
{
k–;
s=(b[j]-‘0’)+car;
p[k]=(s%10)+48;
car=s/10;
j–;
//cout<<p[k];
}
if(car>0)
{
k–;
p[k]=‘1’;
// cout<<p[k];
}
}
fuglo(p,t);
/* for(int g=0;g<t;g++)
{
if(p[g]==‘0’)
ff++;
}
//cout<<ff<<"\n";
if(ff==(t-2))
cout<<p[ff];
//else
//{
for(int o=t-1;o>=0;o--)
{
cout<<p[o];
}
//}*/
}
void fuglo(string &f,int u)
{
int k=0;
reverse(f.begin(),f.end());
if(f[0]==‘0’)
{
for(int i=1;i<u;i++)
{
if(f[i]!=‘0’)
{
k=i;
break;
}
}
for(int m=k;m<u;m++)
cout<<f[m];
}
else
{
for(int k=0;k<u;k++)
cout<<f[k];
}
}
my code is showing wrong answer but I think I have covered all test cases please help…