Skip to content

Instantly share code, notes, and snippets.

@Abreto
Created October 5, 2012 04:02
Show Gist options
  • Save Abreto/3838008 to your computer and use it in GitHub Desktop.
Save Abreto/3838008 to your computer and use it in GitHub Desktop.
判断是否回文
/* 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