HDU2163_判断字符串是否为回文_速度较慢

判断长度50以内的字符串是否为回文串
#include
using namespace std;
const int MAX = 55;

bool isPalind(char str[])
{
	int len = strlen(str);
	for(int i = 0, j = len-1; i < j; i++, j--)
	{
		if(str[i] != str[j])
			return false;
	}
	return true;
}
int main(void)
{
	char str[MAX];
	int cas_c = 1;
	while(scanf("%s", str), strcmp(str, "STOP") != 0)
	{
		printf("#%d: ", cas_c++);
		if(isPalind(str))
			printf("YES\n");
		else
			printf("NO\n");
	}
}
原文地址:https://www.cnblogs.com/cchun/p/2520210.html