// 判断字符串是否为回文.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string.h>
int invert(char str[])
{
int i=0;
int j;
int len=strlen(str);
j=len-1;
while ((i<j)&&(str[i]==str[j]))
{
i++;
j--;
}
if (j<=i)
{
return 1;
}
else
{
return 0;
}
}
int main(int argc, char* argv[])
{
char t[13];
printf("输入字符串:");
gets(t);
if (invert(t))
{
printf("是回文!\n");
}
else
{
printf("不是回文!\n");
}
return 0;
}
判断字符串是否为回文
最新推荐文章于 2025-01-05 16:18:41 发布