Advertisement
rootuss

hanoi

Nov 21st, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. void oblicz(int n, char a, char b, char c)
  7. {
  8.     if(n>0)
  9.     {
  10.         oblicz(n-1,a,c,b);
  11.         cout<<a<<" na "<<b<<endl;
  12.         oblicz(n-1,c,b,a);
  13.     }
  14.  
  15. }
  16.  
  17. int main()
  18. {
  19.     int m;
  20.     cout << "Podaj wartosc danej n " << endl;
  21.     cin>>m;
  22.     char x='A',y='B',z='C';
  23.     if(m==0)
  24.     {
  25.         cout<<"KONIEC"<<endl<<endl;
  26.     }
  27.  
  28.  
  29.  
  30.     else
  31.         {
  32.             oblicz(m,x,y,z);
  33.         }
  34.  
  35.  
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement