Saturday, May 22, 2010

Can you give me a c program of palindrome using string functions but without str reverse?

#include %26lt;stdio.h%26gt;





int isPalindromo( char *s ){


char *s2 = s + strlen( s ) - 1;


if( !*s )


return 1;


while( *s++ == *s2-- %26amp;%26amp; *s );


return !*s %26amp;%26amp; *( --s ) == *( ++s2 );


}





int main( int argc, char *argv[] ){


char s[255];





printf( "Texto:" );


gets( s );


printf( "%s \n", isPalindromo( s ) ? "YES" : "NO" );





system( "pause" );





return 0;


}

sweet pea

No comments:

Post a Comment