#include using namespace std; void hanoi (int,char,char,char); int main() { int num; cout << "Benvenuti alla Torre di Hanoi!" << endl ; cout << "I tre pali si chiamano 'a', 'b' e 'c'" << endl ; cout << "Per favore, inserire il numero di dischi." << endl ; cin >> num; hanoi(num, 'a', 'b', 'c') ; system("PAUSE"); return 0 ; } void hanoi( int n , char from , char temp, char to) { if (n==1) cout << from << " --> " << to << endl ; else { hanoi ( (n-1), from, to, temp) ; // chiamata ricorsiva cout << from << " --> " << to << endl ; hanoi ( (n-1), temp, from, to) ; // chiamata ricorsiva } return; }