Created
October 5, 2012 04:02
-
-
Save Abreto/3838008 to your computer and use it in GitHub Desktop.
判断是否回文
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Program E6-4 */ | |
#include <stdio.h> | |
#include <string.h> | |
int main(void) | |
{ | |
int i = 0, l = 0, r = 0; | |
char str[100]; | |
gets(str); | |
l = strlen(str); | |
while( !(!isalpha(str[i]) && i++) && !(!isalpha(str[l]) && l--) && (i<l) && !(r = (isupper(str[i])?tolower(str[i++]):str[i++])-(isupper(str[l])?tolower(str[l--]):str[l--])) || (i<l)&&(!r) ); | |
printf("%s\n", r?"不回文":"回文"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment