回文串判断
#include <stdio.h>
int main(int argc, const char * argv[]) {
char a[101], s[101];
int len, mid, next, top;
gets(a);
len = strlen(a);
mid = len/2 - 1;
// abc cba
top = 0;
for (int i=0; i<=mid; i++) {
s[top++] = a[i];
}
printf("%s", s);
if (len%2 == 0) {
next = mid+1;
}else{
next = mid +2;
}
for (int i=next; i<=len-1; i++) {
if (a[i] != s[--top]) {
break;
}
}
if (top == 0) {
printf("YES");
}else {
printf("NO");
}
return 0;
}