判断回文

bool IsSymmetry(const char* p)
{
assert(p != NULL);
const char* q = p;
int len = 0;
while(*q++!='\0')
{
len++;
}
bool bSign = true;
q = p+len-1;
if (0 < len)
{
for (int i = 0;i < len/2;i++)
{
if(*p++ != *q--){ bSign = false;break;};
}
}
if(bSign==true)
{
printf("Yes!\n");
}
else
{
printf("No!\n");
}
return bSign;
}

你可能感兴趣的:(判断回文)