Created
October 27, 2015 06:59
-
-
Save neanias/dadef3807d4bc2dfdfa5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #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