C语言:判断回文字符串
程序员文章站
2024-01-14 15:01:04
...
#include<stdio.h>
#include<string.h>
#define LEN 100
int huiwen(char *s){
if((s == NULL) || (*s == NULL))
return 0;
char *a = s;
int i = 0,j = 0;
while(*a != '\0'){
a++;
i++;
}
a--;
while(*s != '\0'){
if(*s == *a)
j++;
else
return 0;
s++;
a--;
}
if(j == i)
return 1;
}
int main(){
char s[LEN];
scanf("%s",&s);
if(huiwen(s) == 1)
printf("True");
else
printf("False");
return 0;
}