摘要: 插入排序(递归) #include <stdio.h>#include <stdlib.h> void fun(int *a, int num){ int i = num - 1; int key = a[num]; while (i>0 && a[i]>key) { a[i + 1] = a[i] 阅读全文
posted @ 2020-01-16 13:03 PCDL&TIPO 阅读(493) 评论(0) 推荐(0) 编辑
摘要: 最大公约数(辗转相除法)递归 #include<stdio.h>#include<stdlib.h> void swap(int m, int n){ if (m < n) { int t = m; m = n; n = t; }}int fun(int m,int n){ if (m%n==0) 阅读全文
posted @ 2020-01-16 12:43 PCDL&TIPO 阅读(1495) 评论(0) 推荐(0) 编辑
摘要: 斐波那契数列递归 斐波那契数列(Fibonacci sequence),又称黄金分割数列、因数学家列昂纳多·斐波那契(Leonardoda Fibonacci)以兔子繁殖为例子而引入,故又称为“兔子数列”,指的是这样一个数列:1、1、2、3、5、8、13、21、34、……在数学上,斐波那契数列以如下 阅读全文
posted @ 2020-01-16 12:00 PCDL&TIPO 阅读(3432) 评论(0) 推荐(0) 编辑
摘要: 反转字符串 #include<stdio.h>#include<stdlib.h> int fun(char *a, int len){ if (len == 0 || len == 1) { return 1; } else{ char t; t = *a; *a = *(a + len-1); 阅读全文
posted @ 2020-01-16 11:47 PCDL&TIPO 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 数组求和 #include<stdio.h>#include<stdlib.h> int fun(int a[], int len){ int i,sum=0; if (len == 0) { return 0; } else{ for (i = 0; i < len; i++) { sum += 阅读全文
posted @ 2020-01-16 11:16 PCDL&TIPO 阅读(3791) 评论(0) 推荐(0) 编辑
摘要: 打印i到j #include <stdio.h>#include <stdlib.h>int fun(int m,int n){ int i; i = m; if (i > n) { return -1; } else{ printf("%d ", i, fun(i + 1, n)); }}int 阅读全文
posted @ 2020-01-16 11:01 PCDL&TIPO 阅读(322) 评论(0) 推荐(0) 编辑