Rekursif Balik Kata

Balik kata
Balik kata

 

 

 

 

 

 

 

 

Dalam Bentuk Program C++

#include
#include
class Balik{
friend istream& operator>>(istream&, Balik&);
friend ostream& operator<<(ostream&, Balik&);
public:
void balik_kata();
void balik(int s);
private:
char kata[50];
int n;
};

void Balik::balik_kata(){
cout<<“Masukkan Kata Yang Akan Dibalik : “;
cin>>kata;n=strlen(kata);

cout<<“Kata Setelah Dibalik : “;
balik(n);
}

void Balik::balik(int s){
if (s != -1){
cout<
balik(s-1);
}
}

int main()
{
Balik X;
X.balik_kata();

system (“Pause”);
return EXIT_SUCCESS;
}

 

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s