-3
#include<iostream>

class Hanoi {
public:
  Hanoi();
  void solve(int, char, char, char);
};

Hanoi :: Hanoi() {
}

void Hanoi :: solve(int n, char from, char use, char to) {
  if (n > 0) {
    solve(n-1, from, use, to);
    cout << "Move disk " << n << " from " << from << " to " << to << endl;
    solve(n-1, use, to, from);
   }
}

int main(void) {
  Hanoi h;
  int N;
  cout << "Enter number of disks : " << endl;
  cin >> N;
  h.solve(N,'A','B','C');
  cin >> N;
}
  • Need more info. What do you want to use the linked list to do? Do you know what a linked list is? What have you tried? – Lou Franco Nov 18 '10 at 23:59
  • 1
    This appears to be in the same vein as [this](http://stackoverflow.com/questions/4220788/how-do-i-add-an-array-to-this-closed). Try adding some explanation so we know *what* you're asking and what you don't understand. – Reese Moore Nov 18 '10 at 23:59
  • i have to turn my tower of hanoi into a linked list using the stack function – Jerell Mingo Nov 19 '10 at 00:03
  • using the stack function i will be converting my tower of hanoi program which is currently in recursive function to a linked list – Jerell Mingo Nov 19 '10 at 00:04
  • 2
    -1 @user512893 Your question does not make sense. This may be purely a communication problem, or a problem of a more conceptual nature. How about just posting the assignment, and pointing out the part that you don't understand? – Cheers and hth. - Alf Nov 19 '10 at 00:05
  • sorry if im unclear to you guys thank you for your patience. I did the tower of hanoi in c++ in recursive function. I now have to add a linked list to it. so in order to add a linked list, i have to use the "stack function" – Jerell Mingo Nov 19 '10 at 00:08
  • 3
    @user512893: Just repeating the phrases "linked list" and "stack function" don't make your intent clearer. Do you want to convert the recursive hanoi() to non-recursive? Do you want to change the order of output? – Blastfurnace Nov 19 '10 at 00:32

1 Answers1

1

He wants to make it iterative.

Look here for an answer if iterative.

Community
  • 1
  • 1