![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Jacky1993
这个作者很懒,什么都没留下…
展开
-
将一个非负十进制整数转换成二进制数,用非递归算法和递归算法来实现
void f(int n) //递归 { if( n==0 ) return; f( n/2 ); cout(n%2); } void f()//非递归,栈 { InitStack(S); scanf("%d",N); while(N){ Push(S,N%2); N=N/2; } while( !StackEmpty(S) ){ Pop(原创 2012-10-24 20:30:42 · 5249 阅读 · 1 评论 -
数据结构 汉诺塔 递归与非递归的实现
递归算法 #include #include"time.h" static int c=0; void move(char x,int n,char z) {//移动函数 printf("第%d步: 将第%i个盘子从%c 盘移动到%c \n",++c,n,x,z); } void hanoi(int n,char x,char y,char z) {汉诺塔递归函数原创 2012-11-07 22:26:37 · 733 阅读 · 0 评论