SPOJ ADDREV – Adding Reversed Numbers solution in c

Problem Link: ADDREV – Adding Reversed Numbers

 

#include<stdio.h>

int main()
{
    int _test,_loop1;
    scanf("%d",&_test);
    for(_loop1=1;_loop1<=_test;_loop1++){
    int _num1, _num2;
    scanf("%d %d",&_num1,&_num2);
    int _rev1,_rev2;
    for(_rev1=0;_num1>=1;_num1=_num1=_num1/10)
        _rev1=_rev1*10+_num1%10;
    for(_rev2=0;_num2>=1;_num2=_num2/10)
        _rev2=_rev2*10+_num2%10;
    int _sum;
    _sum=_rev1+_rev2;
    int _rev_sum;
    for(_rev_sum=0;_sum>=1;_sum=_sum/10)
        _rev_sum=_rev_sum*10+_sum%10;
    printf("%d\n",_rev_sum);
    }
    return 0;
}

Advertisements