#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
int palind(char s[], int len)
{
char cmp[100];
memset(cmp, 0, 100);
int i = 0, j = 0;
/*将str数组中的字符串,按照反序放入到cmp字符数组中*/
for (j = 0, i = len - 1; j < len, i >= 0; i--, j++)
{
cmp[j] = s[i];
}
/*对str和cmp字符数组中的字符串进行比较*/
int result = strcmp(s, cmp);
return result;
}
int main()
{
/*回文字符串*/
char str[100];
scanf("%s", str);
int len = strlen(str);
int result = palind(str, len);
if (0 == result)
{
printf("输入的字符串是回文字符串\n");
}
else
{
printf("输入的字符串不是回文字符串\n");
}
return 0;
}
当输入的字符串为:aabbccccbbaa时
当输入的字符串为:aabbccccddee时