# regarding getting a wrong answer in the lapindrome problem

#include
#include
#include
using namespace std;

int main()
{
unsigned int i,j;
int t;
cin>>t;
while(t–)
{
string str;
cin>>str;
char a[500],b[500];

``````   if(str.length()%2==0)
{
for(i=0;i<((str.length())/2);i++)
{
a[i]=str.at(i);
b[i]=str.at(i+(str.length()/2));
}
}
else
{
for(i=0;i<((str.length()-1)/2);i++)
{
a[i]=str.at(i);
b[i]=str.at((i+(str.length()-1)/2)+1);
}
}

for(i=0;i<str.length()/2;i++)
{
for(j=i;j>0;j--)
{
if(a[j]>a[j-1])
{
a[j-1]=a[j]+a[j-1];
a[j]=a[j-1]-a[j];
a[j-1]=a[j-1]-a[j];
}
if(b[j]>b[j-1])
{
b[j-1]=b[j]+b[j-1];
b[j]=b[j-1]-b[j];
b[j-1]=b[j-1]-b[j];
}
}
}
int flag=0;
for(i=0;i<str.length()/2;i++)
{
if(a[i]!=b[i])
{
flag=1;
break;
}
else{continue;}
}
if(flag==0){cout<<"YES";}
else{cout<<"NO";}
}
return 0;
``````

}
it was my code as an answer to the LAPINDROME problem in Easy problems’ section. I have checked it with numerous test cases and got the correct output always, still it is showing wrong answer.Can anyone tell me the reason?

@debadri1010, There are many things to learn in this field.

A classic mistake made by all the beginners is to miss a new line.
So, you can add new lines whenever you print an output. This is a very common mistake. So you better pay attention to these small things from now on.

``````if(flag==0)
cout<<"YES\n";
else
cout<<"NO\n";
``````

PS: Also, please use the “Code Sample” formatting for writing the code. A better way would have been to give the link for your solution.

//