汉诺塔 游戏版本

 #include<iostream>
using namespace std;
int A[4][7]={{0},{4,11,3,2,1,0,0},{1,11,0,0,0,0,0},{1,11,0,0,0,0,0}};
void show()
{
//for(int i=1;i<=3;i++){ for(int j=0;j<7;j++)  cout<<A[i][j]<<" ";cout<<endl;}
cout<<"---------------------- "<<endl;
for(int i=6;i>0;i--)
  {
   for(int j=1;j<4;j++)  
      {
         if(A[j][i]==0)cout<<"                           ";
         if(A[j][i]==1)cout<<"            [1]            ";
         if(A[j][i]==2)cout<<"          [  2  ]          ";
         if(A[j][i]==3)cout<<"         [   3   ]         ";
         if(A[j][i]==4)cout<<"        [    4    ]        ";
         if(A[j][i]==5)cout<<"       [     5     ]       ";
        if(A[j][i]==11)cout<<"[-------------------------]";           
      }
   cout<<endl;
  }
}
void play()
{
int m,n;

show();
cout<<"  enter  m  to   n  "<<endl;
cin>>m>>n;
if(m==n)play();
if(1>m||m>3||1>n||n>3)play();
if(A[m][A[m][0]]<A[n][A[n][0]])
{
A[n][0]++;
A[n][A[n][0]]=A[m][A[m][0]];
A[m][A[m][0]]=0;    A[m][0]--;
}

play();
}
int main()
{ 
	play();
	return 0;
}