#include<stdio.h>
#include<malloc.h>
#include<string.h>
int fun(char *s)
{
int i,j;
for(i=strlen(s)-1,j=0;i>j;i--,j++)
{
if(s[i]==s[j])
continue;
else
return 0;
}
if(i<=j)
return 1;
}
int fun2(char *s)
{
char *lp,*rp;
lp=s; //将s的首地址赋给lp
rp=s+strlen(s)-1; //将s的尾地址赋给rp
while(*lp==*rp && lp<rp) //比较lp和rp所指值
{
lp++;
rp--;
}
if(lp<rp)
return 0;
else
return 1;
}
void main()
{
char *s;
s=(char *)malloc(sizeof(char)); //将s指向一个新开辟的空间
printf("please input string:");
scanf("%s",s);
printf((fun(s)?"This string is plalindrome!\n":"This string isn't plalindrome!\n"));
}