温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

汉诺塔 游戏版本

发布时间:2020-07-14 16:35:19 来源:网络 阅读:223 作者:wzdouban 栏目:编程语言
 #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;
}


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI