Wednesday 30 December 2015

Program membalik kata di Dev C++

#include <iostream>
#include <string.h>

using namespace std;

int main(int argc, char** argv)
 { system("color b");
 char kal[50];
 int kali;
  cout<<"|=========================|\n";
cout<<"|Menentukan kata Palindrom|\n";
  cout<<"|=========================|\n";
cout<<"|Thedi Wrys  (1500018081) |\n";
cout<<"|=========================|\n\n";
 cout<<"kata :";cin>>kal;
 kali=strlen(kal);

 for(int i=0;i<kali;i++){
  if(kal[i]!=kal[kali-1-i]){
   cout<<"bukan Palindrom:";
   i=kali; }
 
  else{
  cout<<"Palindrom"; i=kali; }
 }
 cout<<endl;
 for(kali=strlen(kal)-1;kali>=0;kali=kali-1)
 {
  cout<<kal[kali]; }
 return 0;
}
Palindrom
thediwrys.blogspot.com

No comments:

Post a Comment