met mencoba ycc ^_^
#include <iostream.h>
#include <string.h>
#include <conio.h>
int ispolyndrome(char[]);
int main(){
char s[1];
cout <<"masukkan kata : ";
cin>>s;
if(ispolyndrome(s))
cout <<s<<" adalah polyndrome";
else
cout <<s<<" bukan polyndrome";
getch();
return 0;
}
int ispolyndrome(char text[100]){
int len=strlen(text), count=0;
char cpytext[100];
strcpy(cpytext, text);
for(int i=0,j=len-1; i<len; i++, j--){
if(cpytext[j]==text[i]) count++;
}
if(count==len)
return 1;
else
return 0;
Tidak ada komentar:
Posting Komentar