- 博客(2)
- 收藏
- 关注
原创 2021-03-28
【C语言】递归-汉尼塔问题 问题描述: 有三个柱子A、B、C,A柱子上有按从上到下的顺序从小到大叠在一起的n个圆盘,要把这些圆盘移动到c柱上去,要求每次只能移动一个圆盘,而且在移动的过程中盘子的顺序不能发生改变。 思路:把问题分解成三个小问题: 1.把A柱上的n-1个圆盘移动到B柱上; 2.把A柱上剩下来的一个圆盘移动到C柱上; 3.吧B柱上的n-1个圆盘移动到C柱上。 代码: #include<stdio.h> void Move(char source,char target); void
2021-03-28 19:26:38
90
原创 2021-03-24
【C语言学习 输入任意位数的整数,结果逆序输出 //input a integer of arbitraily digit int main(){ int i,a,x=0,i2=0;//'i' is integer of input;'a' is used to count the digit of a;'x' is the digit of 'a';'i2' is used to count the resersed integer. scanf("%d",&i); a=i
2021-03-24 22:51:58
45
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人