C-Kurs/Palindrome/Musterlösung
< C-Kurs | Palindrome(Weitergeleitet von Ckurs/Palindrome/Musterlösung)
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> int is_palindrome(char *word){ size_t len = strlen(word); int i; for(i = 0; i < len; i++){ if(tolower(word[i]) != tolower(word[len - i - 1])) return 0; } return 1; } int main(int argc, char **argv){ if(argc != 2){ printf("usage: palindrome <word>\n"); exit(EXIT_FAILURE); } printf("%s ist %s\n", argv[1], is_palindrome(argv[1]) ? "ein Palindrom" : "kein Palindrom"); return 0; }