博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hanoi(栈实现)
阅读量:4703 次
发布时间:2019-06-10

本文共 546 字,大约阅读时间需要 1 分钟。

 

1 #include 
2 #include
3 using namespace std; 4 stack
S[3]; 5 int ans; 6 void move(int x,int y){ 7 int temp=S[x].top(); 8 S[x].pop(); 9 S[y].push(temp);10 cout<
<<" --> "<
<
>n;25 for(int i=n;i>=1;i--){26 S[0].push(i);27 }28 hanoi(0,1,2,n);29 while(!S[2].empty()){30 S[2].pop();31 }32 cout<<"¹²"<
<<"´Î";33 return 0;34 }

 

转载于:https://www.cnblogs.com/zuiaimiusi/p/10843072.html

你可能感兴趣的文章
【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix
查看>>
正则表达式的性能评测
查看>>
CF1172B Nauuo and Circle
查看>>
CF1178D Prime Graph
查看>>
CF1190D Tokitsukaze and Strange Rectangle
查看>>
CF1202F You Are Given Some Letters...
查看>>
CF1179C Serge and Dining Room
查看>>
CF1168B Good Triple
查看>>
CF1208E Let Them Slide
查看>>
CF1086E Beautiful Matrix
查看>>
在单位上班的25条建议(建议收藏)
查看>>
web前端--http协议
查看>>
欧拉定理证明&阶乘的逆元
查看>>
Prime Game Gym - 101981J(网络流/二分图)
查看>>
Teamwork Gym - 101492E (dp)
查看>>
No Link, Cut Tree! Gym - 101484F(dp)
查看>>
Coprimes Gym - 101492C(bitset)
查看>>
Partial Tree UVALive - 7190(完全背包)
查看>>
『深度应用』NLP机器翻译深度学习实战课程·零(基础概念)
查看>>
『开发技术』Windows极简安装使用face_recognition实现人脸识别
查看>>