Files
ARPZ_s1_pr4/alg_4_6.cpp

26 lines
428 B
C++

#include <iostream>
using namespace std;
void move(int a, int b, int c, int n)
{
if (n == 1)
{
cout << "from " << a << " to " << c << endl;
}
else
{
move(a, c, b, n - 1);
cout << "from " << a << " to " << c << endl;
move(b, a, c, n - 1);
}
}
int main()
{
int n;
cout << "Enter the amount of disks: "; cin >> n;
move(1, 2, 3, n);
}