Skip to content

Instantly share code, notes, and snippets.

@neanias
Created October 27, 2015 06:59
Show Gist options
  • Select an option

  • Save neanias/dadef3807d4bc2dfdfa5 to your computer and use it in GitHub Desktop.

Select an option

Save neanias/dadef3807d4bc2dfdfa5 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int is_palindrome(char* word)
{
int length = strlen(word);
for (int i = 0; i < length; ++i) {
for (int j = (length - 1); j > i; --j) {
if (tolower(word[i]) != tolower(word[j])) {
return 0;
}
return 1;
}
}
}
int main(int argc, char *argv[])
{
for (int i = 1; i < argc; ++i) {
if (is_palindrome(argv[i])) {
printf("%s\n", argv[i]);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment