Added my works from 2022

This commit is contained in:
2024-11-21 09:11:52 +03:00
parent facd000301
commit 02068890a5
7 changed files with 161 additions and 0 deletions

26
alg_4_6.cpp Normal file
View File

@@ -0,0 +1,26 @@
#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);
}