Monday, 12 February 2018

Honoli tower problem in data structure

#include<iostream>
using namespace std;
void HanoliTower(int numf,string a,string b,string c)
{
  if(numf==1)
  {
        cout<<"Move Plate "<<numf<<" from "<<a<<"  to "<<c<<endl;

  }
  else {
 
  HanoliTower(numf-1,a,c,b);
 
  cout<<"Move Plate "<<numf<<" from "<<a<<" to "<<c<<endl;

      HanoliTower(numf-1,b,a,c);
      }
}
int main()
{
    HanoliTower(3,"Tower 01","Tower 02","Tower 03");

}

No comments:

Post a Comment