Sir, please tell me where my code is wrong.Most of test case i tried is correct but still not getting A.C.
code:
//no #include
using namespace std;
int main()
{
int t;cin>>t;
while(t–)
{
int a,b;
cin>>a>>b;
int a1,a0,b1,b0,sum=0;
a0=a%10;
b0=b%10;
a1=a/10;
b1=b/10;
if(a1>b0&&b1>a0)
{
sum=a+b;
}
else if(b0>=a0)
{
if(b0>=a1)
sum=(b010)+a0+(b110)+a1;
else if(a0>=b1)
sum=(a010)+b0+(a110)+b1;
}else if(a0>=b0)
{
if(a0>=b1)
sum=(a010)+b0+(a110)+b1;
else if(b0>=a1)
sum=(b010)+a0+(b110)+a1;
}
cout<<sum<<endl;
}
return 0;
}
#include <stdio.h>
int swap(int *x, int *y);
int main()
{
int t,m,n,i,digit1[5],digit2[5],temp,sum;
scanf("%d",&t);
for (i=0;i<t;i++){
scanf("%d %d",&m,&n);
if (m<n) swap(&m,&n);
digit1[1]=m/10;
digit1[0]=m-(digit1[1]*10);
digit2[1]=n/10;
digit2[0]=n-(digit2[1]*10);
if (digit1[1]==0 && digit2[1]==0) sum=m+n;
else {
if (digit2[1]==0 && digit1[1]!=0){
if (digit2[0]>digit1[1]) swap(&digit2[0],&digit1[1]);
}
else if (digit1[1]!=0 && digit2[1]!=0){
if (digit2[0]>digit1[1] && digit2[0]>digit1[0]){
swap(&digit2[0],&digit1[1]);
}
else if (digit1[0]>digit2[1]){
swap(&digit1[0],&digit2[1]);
}
}
sum=(digit1[1]*10)+digit1[0]+(digit2[1]*10)+digit2[0];}
printf("%d\n",sum);
}
return 0;
}
int swap(int *x, int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
return 0;
}
whats wrong with this code can anyone help me?