Last active
November 7, 2020 18:40
-
-
Save codepainkiller/62d602cf7aac554b9821 to your computer and use it in GitHub Desktop.
Torres de Hanoi - C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
using namespace std; | |
int hanoi(int n) | |
{ | |
if(n == 1) | |
return 1; | |
else | |
return 2 * hanoi(n-1) + 1; | |
} | |
int main() | |
{ | |
int discos ; | |
cout<< " TORRES DE HANOI \n\n"; | |
cout<< "Numero de discos: "; | |
cin>> discos; | |
cout<<"\nMovimientos necesarios: "; | |
cout<< hanoi(discos); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment