#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"); } }
判断长度50以内的字符串是否为回文串
转载于:https://www.cnblogs.com/cchun/archive/2012/02/07/2520210.html