سلام
اینم حل برنامه برج هانوی ، ساده ساده میگی نه نگاه کن .gif)
.gif)
__________________________________________________ _____
#include <iostream.h>
#include <conio.h>
//-------------- hanoi function -----------------------
int counter=0;
void hanoi(int n,int a,int b,int c)
{
counter ++;
if (n==1)
cout<< a <<" -> "<< c <<endl;
else
{
hanoi (n-1,a,c,b);
cout<< a <<" -> "<< c << endl;
hanoi (n-1,b,a,c);
}
}
//-------------- main function -----------------------
int main()
{ int n;
cout<< " please enter disk number : ";
cin>>n;
cout << "execution with "<< n <<" disk: "<<endl<<endl;
hanoi (n,1,2,3);
cout<< endl <<"******** executed in " <<counter <<" step. ********"<< endl;
getch();
return 0;
}
__________________________________________________ _______
امیدوارم مفید باشه . .gif)
.gif)
.gif)
.gif)
.gif)
.gif)
.gif)
.gif)