#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <Windows.h>
//判断aaaabbbbaaaa字符串,是否为回文字符串
int a(char* str) {//子函数体,返回int型,小括号是指针字符串
char* shou = str;//字符串首地址赋值给shou
char* mo = str + strlen(str) - 1;//计算出末尾元素地址
while (shou<mo)//判断循环条件
{
if (*shou != *mo) {//shou != mo 返回int型的0值,return退出整个子函数
return 0;//咱们这个字符串不会执行到这里
}
shou++;//在if判断外执行首地址左移,末尾地址友移
mo--;
}
return 1;//while循环结束后返回1值,执行return退出子函数体
}
int main(void)
{
char* str = "aaaabbbbaaaa";//指针类型的字符串
int res= a(str);//调用函数,子函数的返回值int赋值给res
if (res == 0) {//返回值等于0打印不是回文字符串
printf("%s不是回文字符串",str);
}
else if (res==1)//返回值等于1打印是回文字符串
{
printf("%s是回文字符串",str);
}
return EXIT_SUCCESS;
}