![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C
章鱼哥历险记
我就是章鱼哥
展开
-
有雌雄一对兔子,假定过两个月便可繁殖雌雄各一的一对小兔子。问过n个月后共有多少对兔子?递归函数解决
#include int main(){ int f(int n); //声明函数 printf("%d",f(4)); return 0;}//递归函数int f(int n){ int sub;//递归头 if(n==1||n==0) { sub=1; }//递归体 else { sub=f(n-2原创 2017-07-25 11:49:49 · 9512 阅读 · 1 评论 -
魔术师发牌问题 C语言
#include #include #define LEN sizeof(struct magic)typedef struct magic{ //结构体,包含一个整形和一个指针; int no; struct magic *next;}PAI;int a[14]={0}; //包含原创 2017-09-02 15:32:51 · 1231 阅读 · 0 评论 -
将一个链表按逆序排列,即将链头当链尾,链尾当链头。
#include #include #define LEN sizeof(struct student)int n=0;struct student{ //学生结构体节点int num;char name[20];struct student *next;};struct stude原创 2017-08-10 21:51:34 · 5675 阅读 · 1 评论 -
建立一个链表,每个结点数据包括:学号、姓名,性别、年龄。输入一个年龄,如果链表中的结点所包含的年龄等于此年龄,则将此结点删去。
#include #include #define LEN sizeof(struct student)int n=0;struct student{int age;long num;char name[20];unsigned char sex;struct student *next;};struct student *creat(){原创 2017-08-10 17:43:46 · 22405 阅读 · 2 评论 -
有两个链表a和b,设结点中包含学号和姓名,从a链表中删除和b链表中相同学号的结点
#include #include #define LEN sizeof(struct student)#define NULL 0int n=0;struct student {int num;char name[20];struct student *next;};struct student *creat(void) //创建学生结构体链表{ struct原创 2017-08-10 17:10:26 · 3335 阅读 · 0 评论 -
13个人围成一圈,从第一个人开始顺序报号1、2、3,凡是报到3的人退出圈子。最后留的人是几号?
#include #include struct person{int num;struct person *next;}per[13];struct person *creat(void){ struct person *p1=&per[0]; struct person *p2=&per[0]; int i,j=1;f原创 2017-08-10 12:16:29 · 5678 阅读 · 0 评论 -
已有a,b两个链表,每个链表中的结点包括学号,成绩。要求把两个链表合并,按学号升序排列。
#include #include #define LEN sizeof(struct student)#define NULL 0int n=0;struct student {int num;char name[10];struct student *next;};struct student *creat(void){ /原创 2017-08-10 11:14:41 · 7187 阅读 · 2 评论 -
汉诺塔问题
汉诺塔问题:设有三个塔座,依次命名为x,y,z。有z个直径不同的圆盘,由小到大依次编号为1、2、……,n。开始时,它们全部按递减的次序插在塔座上。现要求按下列规则把n个圆盘按次序插放在z塔座上。 (1)、每次只能移动一个圆盘; (2)、圆盘可以从任一个塔座上移到另一个塔座上; (3)、任何时刻都不能把一个较大的圆盘压在较小的圆盘上。#include void main(){v原创 2017-07-25 12:44:57 · 309 阅读 · 0 评论 -
著名的菲波拉契(Fibonacci)数列,其第一项为0,第二项为1,从第三项开始,其每一项都是前两项的和。编程求出该数列前N项数据。
#include int main(){ int f(int n); void k(int n); k(10); return 0;}// 遍历打印函数void k(int n){ for(;n>0;n--) {printf("%d\n",f(n)); } }//递归函数int f(int n){ int sub;原创 2017-07-25 12:33:24 · 19925 阅读 · 2 评论 -
一个人赶着鸭子去每个村庄卖,每经过一个村子卖去所赶鸭子的一半又一只。这样他经过了七个村子后还剩两只鸭子,问他出发时共赶多少只鸭子?经过每个村子卖出多少只鸭子?
#include int main(){ int f(int n); f(1); return 0;}int f(int n){ int sub; if(n==7){ sub=2; printf("经过第%d个村庄时还剩下%d只鸭子\n",n,sub); }else {sub=(f(n+1)+1)*2; printf原创 2017-07-25 12:16:21 · 14538 阅读 · 1 评论 -
英文字幕单词统计软件
自己写的一个小小软件,献给看美剧学英文的同学; QT写的 有点大 别介意链接: https://pan.baidu.com/s/1o768hsv8Z3_sioogKksazQ 密码: 35rn原创 2018-04-12 17:03:14 · 679 阅读 · 0 评论