469,926 Members | 1,533 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

c program to implement oprations on tower of hanoi

This operation involves push/pop operations on a stack,arranging the smaller discs to sit on larger ones.How can I write a program to implement this?
Oct 27 '06 #1
2 4864
9,065 Expert Mod 8TB
Use linked lists to create your stack.
Oct 27 '06 #2
106 100+
here's the code hunny ...

it took me 4 hours to get it ...tracing this code is like hell

# include <iostream.h>
# .....

void towers(int n,char frompeg,char topeg,char auxpeg)

if(n==1) //if only one disk just make the move and return
cout<<"\n"<<"move disk 1 from peg"<<frompeg<<"to peg"<<topeg<<"\n";
cout<<"\n"<<"move disk"<<" "<<n<<"from peg"<<frompeg<<"to peg"<<topeg<<"\n;



void main()
{ int n;
cout<<"enter no of disks 2 be moved "<<endl;

Oct 27 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by elsheikhmh | last post: by
2 posts views Thread by Marco Ippolito | last post: by
7 posts views Thread by ashishnh33 | last post: by
reply views Thread by huzaifaa | last post: by
3 posts views Thread by kamvisiouma | last post: by
3 posts views Thread by shaghayeghcute2003 | last post: by
11 posts views Thread by 960392954 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.