判断字符串是否对称,且不能用字符串的系统函数。
#include <iostream.h>
int StrSymmetry(char *c)
{
char *x = c;
int n=0;
while(*x)
{
x++;
n++;
}
x--;
for(int i = 0; i < n/2; i++)
{
if((*c)^(*x))
{
return 0;
}
else
{
c++;
x--;
}
}
return 1;
}
void main()
{
char *str = "ab123321ba";
cout<<StrSymmetry(str)<<endl;
}