/ Published in: C
Check if the given string is a palindrome.
Expand |
Embed | Plain Text
#include<stdio.h> #include<string.h> int isPalindrome(char *word) { if(NULL == word) return 0; int length = strlen(word); if(1 == length || 0 == length) return 1; int start = 0; while(word[start] == ' ') start++; int end = length - 1; while(word[end] == ' ') end--; for(int i = start, j = end; i<=j; i++, j--) { if(word[i] == ' ' || word[j] == ' ') return 0; if(word[i] != word[j]) return 0; } return 1; } int main() { return 0; }
You need to login to post a comment.
