//已知中文字符占用两个字节
#include <stdio.h> #include <string.h> bool judge(char* a, int& i, int& k); int main() { int i, k; char a[100]; while (scanf("%s", a) != EOF) { i = 0; k = strlen(a) - 1; while (i < k && judge(a, i, k)); if (i >= k) { printf("Yes\n"); } else { printf("No\n"); } } } bool judge(char* a, int& i, int& k) { if (a[i] >= 0 && a[i] == a[k])//英文字符和数字ASCII值大于0 { i++; k--; return true; } else if (a[i] < 0 && a[k] < 0)//中文字符ASCII值小于0 { if (a[i] == a[k - 1] && a[i + 1] == a[k]) { i += 2; k -= 2; return true; } return false; } else return false; }
标签:20,int,C语言,char,judge,&&,字符串,return,else From: https://www.cnblogs.com/wlxdaydayup/p/17337856.html