### Towers of hanoi iterative solution C++

I created an iterative solution for towers of hanoi problem, i want to know if can i do simpler my code, without queues, arrays or vectors.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135`` ``````//Author Juan Enrique Hernández Pérez //TowerOfHanoiIterative.cpp //Iterative solution for the Towers of hanoi problem #include using std::cout; using std::cin; using std::endl; bool isEven(int disks); //function prototype isEven int moves(int disks); //function prototype moves void MoveTower(int disks,int numberOfMovesToSolve,int src,int tmp,int dst); //function prototype MoveTower void MoveSingle(int src,int dst); //function prototype MoveSingle int whichDisk(int movement,int disks); //function prototype whichDisk int patronNumber(int movement,int whichDisk, int disks); //function prototype patronNumber int main(){ int disks; int src,tmp,dst; int numberOfMovesToSolve; cout<<"Number of disks: "; cin>>disks; cout<<"Initial peg: "; cin>>src; cout<<"Temporal peg: "; cin>>tmp; cout<<"Destination peg: "; cin>>dst; numberOfMovesToSolve=moves(disks); MoveTower(disks,numberOfMovesToSolve,src,tmp,dst); return 0;//indicates success }//end main bool isEven(int disks) { bool isEven; if(disks%2==0) isEven=true; else isEven=false; return isEven; }//end function isEven int moves(int disks) { int moves=0; for(int i=1;i<=disks;i++){ moves=(moves*2)+1; }//end loop for return moves; }//end function moves void MoveTower(int disks,int numberOfMovesToSolve,int src,int tmp,int dst){ if(!isEven(disks)){ //isNotEven for(int movement=1;movement<=numberOfMovesToSolve;movement++){ switch(patronNumber(movement,whichDisk(movement,disks),disks)){ case 1: if(!isEven(whichDisk(movement,disks)))MoveSingle(src,dst); else MoveSingle(src,tmp); break; case 2: if(!isEven(whichDisk(movement,disks)))MoveSingle(dst,tmp); else MoveSingle(tmp,dst); break; case 3: if(!isEven(whichDisk(movement,disks)))MoveSingle(tmp,src); else MoveSingle(dst,src); break; }//end switch }//end loop for }else{ //isEven for(int movement=1;movement<=numberOfMovesToSolve;movement++){ switch(patronNumber(movement,whichDisk(movement,disks),disks)){ case 1: if(!isEven(whichDisk(movement,disks)))MoveSingle(src,tmp); else MoveSingle(src,dst); break; case 2: if(!isEven(whichDisk(movement,disks)))MoveSingle(tmp,dst); else MoveSingle(dst,tmp); break; case 3: if(!isEven(whichDisk(movement,disks)))MoveSingle(dst,src); else MoveSingle(tmp,src); break; }//end switch }//end loop for }//end if...else }//end function MoveTower void MoveSingle(int src,int dst){ cout<"<
 ``` ./TowerOfHanoiIterative Number of disks: 3 Initial peg: 1 Temporal peg: 2 Destination peg: 3 1--->3 1--->2 3--->2 1--->3 2--->1 2--->3 1--->3 ./TowerOfHanoiIterative Number of disks: 4 Initial peg: 1 Temporal peg: 2 Destination peg: 3 1--->2 1--->3 2--->3 1--->2 3--->1 3--->2 1--->2 1--->3 2--->3 2--->1 3--->1 2--->3 1--->2 1--->3 2--->3 ```