WA in SWPDGT

///////////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
int main()
{
int T;
scanf("%d",&T);
for(int k=0;k<T;k++)
{
int A,B,At,Ao,Bt,Bo;
int S1=0,S2=0,S3=0,S4=0; // sums were not initialized which gave them garbage value
scanf("%d %d",&A,&B);
At=A/10;
Ao=A%10;
Bt=B/10;
Bo=B%10;
S1=A+B;
// at A=3 B=2 then answer must be 5 but you gave 32 because you considered 2 as 02 and 3 as 03 and swapped the zeroes
if(Bt!=0)
S2=At 10+Bt+Ao 10+Bo;
if(At!=0)
S3=Bt 10+At+Bo 10+Ao;
if(S1>=S2&&S1>=S3)
printf("%d\n",S1); //after printing answer line was not changed
else if(S2>=S1&&S2>=S3)
printf("%d\n",S2); //after printing answer line was not changed
else if(S3>=S1&&S3>=S2)
printf("%d\n",S3); //after printing answer line was not changed
}
}
///////////////////////////////////////////

I have corrected your code and commented the mistakes :slight_smile:
you can try this code now

You should put ``` above and below the code, to format your code correctly. @ankurrathiiit

1 Like