// http://www.spoj.com/problems/ADDREV/
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
int main(int argc, char* argv[])
{
using std::string;
using std::reverse;
int N = 0;
std::cin >> N;
while ( N>0 ) {
N--;
int a, b;
std::cin >> a >> b;
string ra, rb;
std::ostringstream itoaa, itoab;
itoaa << a;
ra = itoaa.str();
itoab << b;
rb = itoab.str();
std::reverse(ra.begin(), ra.end());
std::reverse(rb.begin(), rb.end());
std::istringstream atoia(ra);
atoia >> a;
std::istringstream atoib(rb);
atoib >> b;
int sum = a + b;
std::ostringstream itoasum;
itoasum << sum;
string result = itoasum.str();
std::reverse(result.begin(), result.end());
std::istringstream atoisum(result);
atoisum >> sum;
std::cout << sum << std::endl;
}
return 0;
}
Adding Reversed Numbers
最新推荐文章于 2024-04-18 23:25:48 发布