ADDREV spoj problem
#include<iostream>
using namespace std;
int reverse(int n);
int add(int n, int m);
int main()
{
int a,b,t;
cin>>t;
while(t--)
{
cin>>a>>b;
int e=add(reverse(a),reverse(b));
cout<<reverse(e)<<endl;
}
return 0;
}
int reverse(int n)
{ int sum=0;
while(n>0)
{
int r=n%10;
sum=sum*10+r;
n=n/10;
}
return sum;
}
int add(int n,int m)
{
return (n+m);
}
#include<iostream>
using namespace std;
int reverse(int n);
int add(int n, int m);
int main()
{
int a,b,t;
cin>>t;
while(t--)
{
cin>>a>>b;
int e=add(reverse(a),reverse(b));
cout<<reverse(e)<<endl;
}
return 0;
}
int reverse(int n)
{ int sum=0;
while(n>0)
{
int r=n%10;
sum=sum*10+r;
n=n/10;
}
return sum;
}
int add(int n,int m)
{
return (n+m);
}
No comments:
Post a Comment