标题:[转载]Tower of Hanoi
只看楼主
指向指针的指针
Rank: 1
等 级:新手上路
帖 子:339
专家分:0
注 册:2004-8-8
 问题点数:0 回复次数:0 
[转载]Tower of Hanoi


hey guys .. this is an amazing code to solve the tower of Hanoi problem .. done without any recurtion and stack use .. check this out ..
// just copy paste this into a .c file and // use gcc to compile .. ( for linux .. )

main(
){int
z,y,n
;scanf("%d",&n);
for(y=1;(1<<n)-y
;y<<=z-1,printf(
"disk %i from %i to %i.\n"/**/
,z,(y&y-1)%3,((y|y-1)+1)%3),y
++)for(z=1;!(y&1);z++,y>>=1);}

搜索更多相关主题的帖子: Hanoi Tower 
2006-07-06 11:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-76864-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051531 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved