Tower of Hanoi Using Recursion in C++/C in Data Structure

Tower of Hanoi Using Recursion in C++/C  in Data Structure 

#include <bits/stdc++.h>

using namespace std;
void TOH(int n, int A, int B, int C){
if(n>0){
TOH(n-1, A,C,B);
cout<<"("<<A<<","<<C<<")"<<" ";
TOH(n-1,B,A,C);
}
}
int main() {
TOH(3,1,2,3);
return 0;
}

Post a Comment

0 Comments