Switch to full style
For C/C++ coders discussions and solutions
Post a reply

Circular Queue

Fri Nov 07, 2008 5:29 pm

I'm trying to write a program that can read in a string of data and
determine if it is a pack palindrome.



Re: Circular Queue

Fri Nov 07, 2008 5:32 pm

check this pice of code

Code:
#include <stdio.h>

#define PALINDROME 0
#define NOT_PALINDROME 1

main()
{
        char buff[512];

        printf("Enter a string: ");
        scanf("%s", buff);

        if (palindrome(buff) == PALINDROME) {
                printf("String is palindrome\n");
        }
        else {
                printf("String is not a palindrome\n");
        }

}
int palindrome(char *ptr)
{
        int strbeg = 0, strend = 0;

        strend = strlen(ptr) - 1;
        while ( strbeg == strend || strbeg < strend) {
                if (ptr[strbeg] != ptr[strend])
                        return (NOT_PALINDROME);

                strbeg++;
                strend--;
        }
        return (PALINDROME);
}



Post a reply
  Related Posts  to : Circular Queue
 Queue Header     -  
 priority queue     -  
 generic queue     -  
 queue of objects keep track of the front and rear     -