Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void)
- {
- int a,b,T,cur,first,second,res;
- scanf("%d",&T);
- while(T--)
- {
- scanf("%d %d",&a,&b);
- first=rev(a);
- second=rev(b);
- cur=first+second;
- check(cur);
- res= rev(cur);
- printf("%d\n",res);
- }
- return 0;
- }
- void check(int res)
- {
- int idx=0;
- while(res>0)
- {
- if(res%10!=0)
- {
- idx=idx*10+res%10;
- }
- res/=10;
- }
- res=idx;
- }
- int rev(int num)
- {
- int idx=0;
- while(num>0)
- {
- idx=idx*10+num%10;
- num/=10;
- }
- num=idx;
- }
Add Comment
Please, Sign In to add comment