You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
459 B

#include<bits/stdc++.h>
using namespace std;
int isHuiWen(char s[], int len) {
int i, mid = len / 2;//遍历到mid之前的元素停止
for (i = 0; i < mid; i++) {
if (s[i] == s[len - i - 1])continue;
else return 0;
}
return 1;
}
int main(void) {
char str[100];
int len;
fgets(str, sizeof(str), stdin);
len = strlen(str);
printf("%s of size %d\n", str, len);
if (isHuiWen(str, len)) {
printf("YES\n");
} else {
printf("No\n");
}
return 0;
}