Friday, 10 July 2015

ADDREV

Standard

Adding Reversed Numbers

 Link to the question : ADDREV

HINT : 

A very simple question. Just reverse the numbers, add them and reverse it again. Just be careful you use fast I/O.

SOURCE CODE : 

#include<stdio.h>
int rev(int n)
{
    int r,s=0;
    while(n>0)
    {
        r=n%10;
        s=s*10+r;
        n=n/10;
       
    }
    return s;
}
int main()
{
    int n,a,b,c;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d",&a,&b);
        c=rev(a)+rev(b);
        printf("%d\n",rev(c));
    }
    return 0;
}

0 comments:

Post a Comment