Skip to content

Cek palindrom sebuah kata

November 26, 2008

#include iostream.h>
#include conio.h>

void main()
{
char kata[30];
int p,i;
cout<>kata;
p= strlen(kata)-1;
i=0;
bool sama=false;
while(i<=(p/2)) { if (kata[i]==kata[p]) { sama=true; i++; p–;} else {sama=false; i=p; } } if (sama==true) cout<<"Palindrom"; else cout<<"bukan"; getch(); }

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: