Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <stdlib.h>
- void print_move( int from,int to )
- {
- cout<<"Move Disk From "<<from<< " To "<<to<<endl;
- }
- void transfer ( int from,int to,int via,int n )
- {
- if(n==1)
- {
- print_move(from,to);
- }
- else
- {
- transfer(from,via,to,n-1);
- print_move(from,to);
- transfer(via,to,from,n-1);
- }
- }
- void main(int k,char**s)
- {
- if(k>1&&atoi(s[1]))
- {
- transfer( 1,3,2,atoi(s[1]));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement