习题8-8 判断回文字符串 (20 分)
#include <stdio.h> #include <string.h> #define MAXN 20 typedef enum { false, true } bool; bool palindrome(char *s); int main() { char s[MAXN]; scanf("%s", s); if (palindrome(s) == true) printf("Yes\n"); else printf("No\n"); printf("%s\n", s); system("pause"); return 0; } /* 你的代码将被嵌在这里 */ bool palindrome(char *s) { int i; for (i = 0; i < strlen(s) / 2; i++) if (s[i] != s[strlen(s) - 1 - i]) break; if (i == strlen(s) / 2) return true; return false; }