/*Sample Input
3
24 1
4358 754
305
Sample Output
34
1998
*/
#include<iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
void toreverse(char s[])
{
char tmp ,*d = s, *m = s + strlen(s) - 1;
if(!s) return;
while(d < m)
{
tmp = *d;
*d++ = *m;
*m-- = tmp;
}
}
int main(int argc , char * argv[])
{
int N,ai,bi;
char res[10],a[10],b[10];
cin>>N;
while(N--)
{
cin>>a>>b;
toreverse(a);
toreverse(b);
ai = atoi(a);
bi = atoi(b);
sprintf(res,"%d",ai + bi);
toreverse(res);
printf("%d\n",atoi((char *)res));
}
return 0;
}
POJ 1504 Adding Reversed Numbers
原文:http://www.cnblogs.com/guohaoyu110/p/6323775.html