Rabu, 11 April 2012

Algoritma Membalik Kata yang diInputkan [rekursif]

06.07



 Ø  Flowchart :
        
 Ø  Syntax C++ dengan structur class [rekursif] :

#include
#include

using namespace std;
class balik{
      friend ostream& operator<<(ostream&, balik&);
      friend istream& operator>>(istream&, balik&);
public:
        void balik_kata(int x);
private :
        char kata[50];
        int panjangkata;
};

istream& operator>>(istream& in, balik& masuk){
         cout<<"masukkan kata : ";
         in>>masuk.kata;
         masuk.panjangkata=strlen(masuk.kata);
         return in;
         }
ostream& operator<<(ostream& out, balik& keluar){
         cout<<"kata setelah dibalik : ";
         keluar.balik_kata(keluar.panjangkata);
         cout<
         return out;
         }
void balik::balik_kata(int x){
     if(x>=0){
              cout<
              balik_kata(x-1);
              }
              }
int main(int argc, char *argv[])
{
    balik kata;
    cin>>kata;
    cout<
 
    system("PAUSE");
    return EXIT_SUCCESS;
}

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 komentar:

Posting Komentar

 

© 2013 Raizexe Blog. All rights resevered. Designed by Templateism

Back To Top