//ppolindrom
#include <iostream>
using namespace std;
// kamus
string kata;
int n,i,x;
bool palindrom = true;
// deskripsi
int main()
{
cout << " Program mengecek kata - kalimat palindrom atau bukan \n";
cout << " input kata : ";
getline(cin , kata);
n=kata.length();
i=0;
while(i<n)
{
if(kata[i] != kata[n-i-1])
{
palindrom = false;
break;
}
i++;
}
cout << " result : \n";
if(palindrom == true)
{
cout << "Palindrom";
}
else
{
cout << " Bukan Palindrom";
}
cin.ignore();
return 0;
}
Komentar
Posting Komentar