WA in SWAPDGT

#include <stdio.h>

int main(void) {
int t;
int a,b;
int a1,a2,b1,b2;
char c;
scanf("%d",&t);
c = getchar();
for(int i = 0; i<t ; i++)
{
scanf("%d",&a);
c = getchar();
scanf("%d",&b);
c = getchar();

    a1 = a/10;
    a2 = a%10;
    b1 = b/10;
    b2 = b%10;
    
    if(a2>b1 && b2>a1 )
    {
        if(a2>b2)
        {
           printf("%d\n", (a2*10 + a1*10 + b1 +b2) );
        }
        else 
        {
            printf("%d\n",(b2*10 + b1*10 + a1 + a2));
        }
        
    }
    else if(a2>b1)
    {
        printf("%d\n",(a2*10 + a1*10 + b1 +b2));
    }
     else if(b2>a1)
    {
        printf("%d\n",(b2*10 + b1*10 + a1 + a2));
    }
    else 
    {
        printf("%d\n",(a1*10 + b1*10 + a2 +b2));
    }
    
}

}

i don’t get what mistake i did.

This was exactly the blunder i was doing for 20 mins during contest see the mistake is when you encounter a double digit and a single digit you are considering the single digit as 05 which is wrong it must be considered as 5 only at ones place for example i runned your code and for test case 67 5
the answer must be 72 not 135 and for the test case of two single digit its just there sum like 5 6 the answer will be 11 and not 65 so the mistake is in single digit single digit cases and single digit double digit cases

1 Like

https://www.codechef.com/viewsolution/30825589
what mistake i have done here

Please remove harcoding there is no need for that and for case 3 2 the answer will be 5 and for case 56 and 4 answer will be 60 not 69

Thanks