Breaking News
Loading...
Minggu, 17 April 2016

Palindrom Atau Bukan Palindrom

Source Code C++ :



/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
                char kata[15];
                int belakang;
                bool palindrom = true;
                cout<<"masukan kata : ";
                cin.getline(kata, sizeof(kata));
                int panjang = strlen(kata);
                belakang = panjang-1;
                for(int a=0;a<panjang;a++){
                if((char)tolower(kata[a])!=(char)tolower(kata[belakang])){
                                palindrom = false;
                                break;
                }
                belakang--;        
                }
                if(palindrom){
                                cout<<"termasuk palindrom";
                                cout<<endl;
                }
                else
                cout<<" bukan palindrom";
                return 0;
}

Hasilnya :

Raptornya :



 

0 komentar:

Posting Komentar

Copyright © 2014 My Blog My Adventure All Right Reserved