/*** Saeteurn, San ect_sfs@ecst.csuchico.edu Pseudocode For Tower pf Hanoi Problem ***/ #include #include using namespace std; void solve(int n,string src,string aux,string dst); /*** The Main Function ***/ int main() { //In the Assembly Code, the Strings will be replaced with number values //SRC = 1, AUX = 2, DST = 3 string src,aux,dst; //The Variables and Constants src = "SRC"; //Initializing the Constants aux = "AUX"; //Initializing the Constants dst = "DST"; //Initializing the Constants int n = 0; //Number of Disks, initailly set to 0 cout << "Enter number of N: "; cin >> n; if(n < 3 && n > 8) //Check for valid input (Must be 3 or greater but no more than 8) return 1; //If not, exit with error solve(n,src,aux,dst); return 0; } /*** The Solve Function ***/ void solve(int n,string src,string aux,string dst) { if(n == 0)//Terminating Value return; else { solve(n-1,src,dst,aux);//Move From SRC to AUX using DST as Intermediate Peg cout << "Move from " << src << " to " << dst << endl; solve(n-1,aux,src,dst);//Move From AUX to DST using SCR as an Intermediate Peg } }