Over a million developers have joined DZone.

Palindrome :D

·

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com

#include 

int isPalindromo( char *s ){
	char *s2 = s + strlen( s ) - 1;
	if( !*s )
		return 1;
	while( *s++ == *s2-- && *s );
	return !*s && *( --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;
}

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}