Tower of Hanoi is a puzzle game of mathematics, tower of Hanoi is a puzzle invented in 1883. Tower of Hanoi puzzle game consists of 3 Tower of different sizes and disk. Which slide into towers.
tower of Hanoi Profram:
#include<iostream>
using namespace std;
void tower(int d, char tower1, char tower2,char tower3)
{
{
cout<<“shift first disk from towert”<<tower1<<“tto tower”<<tower2<<“nn”;
return;
} // if close here
tower(d-1,tower1,tower3,tower2); // recursive function call
cout<<“shift first disk fromt”<<tower1<<“tto tower”<<tower2<<“n”;
tower(d-1,tower3,tower2,tower1); //recursive function call
}
int main()
{
int disk;
cout<<“enter the number of disknn”;
cin>>disk;
if(disk<1)
cout<<“there are no disks are shiftednn”;
else
cout<<“there are”<<disk<<“disk in towernn”;
tower(disk,’1′,’2′,’3′);
cout<<“nn”<<disk<<“tdisk in tower 1 are shifted to tower 2”;
return 0;
}
Output:
How to add and where to add executable cpp file
write a program to implement selection sort || Executable file download link
C++ PROGRAM TO IMPLEMENT STACK USING ARRAY | with executable cpp file
Program to find factorial of Number in C++ | Interesting321
C++ program to find largest of three numbers using inline function
how to install android os to your pc
how to fix there is something wrong
Program to implement bubble sort
INSTALL G++ COMPILER TO LINUX | C++ Compiler | Full installation process with screenshot
Nice post.Thank you for sharing the information.
moviebox download