https://www.spoj.com/problems/ADDREV/
i tried to do this question using strings and I am getting correct answers on my compiler but spoj says Wrong answer.
here is my code …
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t,x,y,z,i,lol;
cin>>t;
string s1,s2,s3;
while(t–)
{
cin>>s1>>s2;
reverse(s1.begin(),s1.end());
reverse(s2.begin(),s2.end());
x=stoi(s1);
y=stoi(s2);
z=x+y;
s3=to_string(z);
if(z!=0)
{
for(i=0;s3[i]!=’\0’;i++)
{
if(s3[i]==‘0’)
{
s3[i]=’\0’;
break;
}
}
reverse(s3.begin(),s3.end());
}
cout<<s3<<endl;
}
}