spoj problem solution Add Reverse
#include <iostream>
using namespace std;
int reverse(int num)
{
int rev_num = 0;
while(num > 0)
{
rev_num = rev_num*10 + num%10;
num = num/10;
}
return rev_num;
}
int main() {
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
int z=reverse(reverse(x)+reverse(y));
cout<<z<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int reverse(int num)
{
int rev_num = 0;
while(num > 0)
{
rev_num = rev_num*10 + num%10;
num = num/10;
}
return rev_num;
}
int main() {
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
int z=reverse(reverse(x)+reverse(y));
cout<<z<<endl;
}
return 0;
}
No comments:
Post a Comment