- 博客(3)
- 收藏
- 关注

原创 C语言 递归方法计算x的n次方
#include <stdio.h>#include <stdlib.h>int f(int a, int b);int main(){ int x, n; printf("x=? n=?", x, n); scanf("%d%d", &x, &n); printf("%d**%d=%d\n", x, n, f(x, n)); return 0;}int f(int a, int b){ int c=1; for(;b>
2020-05-15 09:29:10
13822
2
原创 汉诺塔(Hanoi)是必须用递归方法才能解决的经典问题。它来自于印度神话。上帝创造世界时作了三根金刚石柱子,在第一根柱子上从下往上按大小顺序摞着64片黄金圆盘,如图7-3所示。上帝命令婆罗门把圆盘从下
#include <stdio.h>void Hanoi(int n, char a, char b, char c);void Move(int n, char a, char b);int main(){ int n; printf("Input the number of disks:"); scanf("%d", &n); printf("Steps of moving %d disks from
2020-05-18 20:38:20
2160
原创 打印出以下图案: * * * * * * * * * * * * * * * * * * * * *
#include <stdio.h>#include <stdlib.h>int main(){int n=4;int i,j,sum;char ch=’’;for(i=1; i<=n; i++){for(j=1; j<=3(n-i); j++){printf(" “);}printf(”");for(sum=2i-1; sum>=2; sum–){printf("%3c",ch);}printf("\n");}for(i=
2020-05-11 18:11:01
5948
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人