struct list_node *pal; //GLOBAL VAR
void PalindromeCheck(struct list_node *node)
{
static int i=1;
static int mid;
i++;
if ( node->next == NULL )
{
pal=head->start;
if (node->data!=pal->data){
printf("\nNot Palindrome\n");
exit(0);
}
else {
i--;
}
mid=i/2;
return;
}
PalindromeCheck(node->next);
pal=pal->next;
i--;
if ((i >= mid) && (node->data!=pal->data)) {
printf("\nNot Palindrome\n");
exit(0);
}
if (i < mid) {
printf("\nPalindrome\n");
exit(0);
}
}
No comments:
Post a Comment