| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:[转载]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
快速回复:[转载]Tower of Hanoi
数据加载中...
 
   



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

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