//思路:递归
#include <stdio.h>
#include<string.h>
int j =0;
char array[128];
void *reverse(char *p)
{
if(*p == '\0')
{
return ;
}
reverse(p+1);
array[j] = *p;
j++;
}
int main()
{
char str[128];
gets(str);//gets();getchar();
reverse(str);
if( strcmp(array,str) == 0)
{
printf("this string is a palindrome\n");
}else
{
printf("this string is not a palindrome\n");
}
}
输出:
eg1:
abad
this string is not a palindrome
eg2:
aba
this string is a palindrome
eg3:
abcdcba
this string is a palindrome
对递归调用不理解的移步 原文链接:https://blog.csdn.net/sugcoffee/article/details/135773759