ADDREV - Adding Reversed Numbers on spoj-
#include<stdio.h>int main ()
{
int n,k,p = 0,q=0,x,a,y,t=0,z,s,i;
scanf("%d\n",&k);
for(i=0;i<k;i++)
{ scanf ("%d%d", &n,&a);
{while (n != 0)
{
x = n % 10;
p = p * 10 + x;
n = n / 10;
}
while(a!=0)
{
y=a%10;
q=q*10+y;
a=a/10;
}
z=p+q;
while(z!=0)
{
s=z%10;
t=t*10+s;
z=z/10;
}
printf("%d\n",t);
t=0;
p=0;
q=0;
}}
return 0;
}
Comments
Post a Comment