SHARE
TWEET

Untitled

a guest May 23rd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void hanoi(int n,char a,char b,char c)
  2. {
  3. if(n==1)
  4.   cout<<"(" <<a<<","<<b<<") ";
  5. else
  6. {
  7.   hanoi(n-1,a,c,b );
  8.   cout<<"("<<a<<","<<b<<" ) ";
  9.   hanoi(n-1,c,b,a);
  10. }
  11. }
  12. int main()
  13. {
  14. int n;
  15. char a='a',b='b',c='c';
  16. cin>>n;
  17. hanoi(n,a,b,c);
  18. return 0;
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top