Program in c++ using RECURSION of TOWER OF HANOI
DESCRIPTION:-
WHAT IS TOWER OF HANOI:-I am uploading a pic of this to better understanding of tower of hanoi problem.
OUTPUT OF THE PROGRAM:-
SOURCE CODE:-
#include<iostream>
DESCRIPTION:-
WHAT IS TOWER OF HANOI:-I am uploading a pic of this to better understanding of tower of hanoi problem.
OUTPUT OF THE PROGRAM:-
SOURCE CODE:-
#include<iostream>
#include<conio .h>
using namespace std;
int toh(int n,int beg,int aux,int end)
{
if(n==1)
{
cout<< beg<<"->"<
return 0;
}
toh(n-1,beg,end,aux);
cout<< beg<<"->"<
toh(n-1,aux,beg,end);
}
int main()
{
int n,beg=1,aux=2,end=3;
cout<<"Enter no";
cin>>n;
cout<<"\nSteps for Tower Of Honoi are\n";
toh(n,beg,aux,end);
}
/*
THANKU.
0 comments:
Post a Comment