Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <stdio.h>
- void move(int n, int sursa, int destinatie, int intermediar) {
- if (n == 1) {
- return;
- }
- move(n - 1, sursa, intermediar, destinatie);
- move(n - 1, intermediar, destinatie, sursa);
- }
- int main() {
- int n;
- move(n, 1, 2, 3); // muta discurile de pe tija 1 pe 2 folosind intermediar tija 3
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement