#include
#include
#include
/*
* arr[] 字符数组
* halNum 字符数组的一半
* Totmun 字符数组的总长度
*/
bool charf(char arr[], int halNum, int TotNum)
{
if (!arr)
{
return false;
}
bool b = false;
if (arr[halNum] == arr[TotNum - halNum] && halNum == 0)
{
b = true;
}
else if (arr[halNum] == arr[TotNum - halNum])
{
b = charf(arr, halNum - 1, TotNum);
}
return b;
}
int main(int argc, char *argv[])
{
int count = 0;
bool b = false;
char a;
char *arr = (char *)malloc(15);
char *temp1 = arr;
char *temp2 = arr;
memset(arr, '/0', 15);
while ((a = getchar()) != '/n')
{
arr[count++] = a;
}
//除去空格
count = 0;
while (*temp1 != '/0')
{
if (*temp1 != ' ')
{
*temp2++ = *temp1;
count++;
}
temp1++;
}
if (0 == count % 2)
{
b = charf(arr, (count / 2), count - 1);
}
else
{
b = charf(arr, (count / 2 - 1), count - 1);
}
if (b)
{
printf("%s/n", "回文");
}
else
{
printf("%s/n", "不是回文");
}
return 0;
}