In the question where we need to find palindrome substrings in a given string , I wrote the below code, could you kindly point out what is the mistake that I am doing in it ?
#include
#include
using namespace std;
int main() {
char a[1000];
cin.getline(a,1000);
int len;
len= strlen(a)-1;
int cnt = 0;
for(int i =0;i<len;i++)
{
for(int j=0;j<len;j++)
{
int x,y;
x=i;
y=j;
int flag = 0;
while(x<=y)
{
if(a[x]!=a[y])
{
flag++;
}
x++;
y--;
}
if(flag==0)
{
cnt++;
}
}
}
cout<<cnt;
return 0;
}