Wed Jan 23, 2013 4:35 pm
#include<iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
int n,i;
char choise;
do
{
int sum=1;
cout<<"\n\n\t\t\tThe number of disks = ";
cin>>n;
for(i=0;i<n;i++)
sum*=2;
sum-=1;
cout<<"\n\n\tThe number of minimum trials = "<<sum<<endl;
int x;
printf( "How many disks? " );
scanf( "%d", &n );
puts( "\n\n" );
for (x=1; x < (1 << n); x++)
printf( "\t\tmove from pole %i to pole %i.\n",
(x&x-1)%3, ((x|x-1)+1)%3 );
cout<<"\n\n\n\tDo you want check another number?(y/n). ";
cin>>choise;
}while(choise=='y'||choise=='Y');
cout<<endl<<endl<<endl;
cout<<" *** WITH MY BEST WISHES ***"<<endl;
cout<<" <><>"<<endl;
cout<<"Type EXIT to close the program : ";
cin>>choise;
return 0;
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.