一、判断一个字符串是否为回文字符串
#include #include #include //包含strlen
#define YES 1
#define NO 0
#define uchar unsigned char
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long
#define u8 uchar
#define u16 ushort
#define u32 ulong
u8 IsPalindromeString(u8 *pStr);
int main(void)
{
u8 array[] = "abcdefgfedcba";
u8 value = 0;
value = IsPalindromeString(array);
if (value)
{
printf("是回文字符串!\n");
}
else
{
printf("不是回文字符串!\n");
}
return 0;
}
//思路:
//(1)用两个指针分别指向字符串的头和尾
//(2)比较两指针指向的字符是否相同
//(3)若相同则头指针向后移动,尾指针向前移动
//(4)若不同则返回NO,说明不是回文字符串
//(5)重复2.3.4
//(6