首页
友链
统计
留言
关于
Search
1
Java使用poi-tl动态生成word和pdf
465 阅读
2
实现MyBatis拦截器自动填充创建、更新时间等字段属性值
209 阅读
3
Java生成二维码——基于Google插件
196 阅读
4
利用Spring的InitializingBean优雅的实现策略模式
170 阅读
5
springboot整合easyExcel导出excel
163 阅读
默认分类
Java
C语言
数据库技术
Linux
前端
其他
登录
/
注册
Search
标签搜索
C语言
数据结构
Java
Spring
数据库技术
MySQL
Hadoop
MapReduce
大数据
easyExcel
POI
MybatisPlus
AOP
SpringMVC
IDEA
工厂模式
策略模式
设计模式
LiXiangrong
累计撰写
57
篇文章
累计收到
8
条评论
首页
栏目
默认分类
Java
C语言
数据库技术
Linux
前端
其他
页面
友链
统计
留言
关于
搜索到
57
篇与
的结果
2024-01-29
二叉树的链式存储
二叉树的链式存储// 7.3.2 二叉树的链式存储 typedef char dataType; // 结点值的类型 typedef struct node { dataType data; // 结点数据域 struct node *lChild, *rChild; // 左、右孩子指针 struct node *parent; //有时为了方便的找到双亲结点 }treeNode, *binaryTree;
2024年01月29日
52 阅读
0 评论
0 点赞
2024-01-29
二叉树的顺序存储
二叉树的顺序存储1.完全二叉树的顺序存储#define MAX_SIZE 100 typedef char dataType; // 二叉树结点值类型 // 7.3.1.1 完全二叉树的顺序存储 dataType tree[MAX_SIZE]; int n; // 完全二叉树中实际所含结点个数 2.一般二叉树的顺序存储#define MAX_SIZE 100 typedef char dataType; // 结点值的类型 // 7.3.1.2 一般二叉树的顺序存储 typedef struct node { dataType data; // 结点数据域 int lChild, rChild; // 左、右孩子坐标 int parent; //有时为了方便的找到双亲结点 }treeNode; typedef struct binaryTree { treeNode tree[MAX_SIZE]; int n; // 结点个数 int root; // 根结点坐标 }tree;
2024年01月29日
45 阅读
0 评论
0 点赞
2024-01-29
树的遍历(指针方式孩子表示法)
树的遍历(指针方式孩子表示法)#include <stdio.h> #include <stdlib.h> #define MAX_SIZE 100 typedef char dadaType; // 6.4.1 树的遍历(指针方式孩子表示法) #define m 3 //树的度 typedef struct node { dadaType data; struct node *child[m]; // 指向孩子的指针数组 }node, *tree; typedef struct queue // 用于层序遍历的队列 { node data[MAX_SIZE]; int front, rear; // 对头指针和队尾指针 }queue; // 1. 初始化循环队列 void init(queue *q) { q->front = q->rear = 0; } // 2. 判断队列是否为空 int empty(queue q) { return q.rear == q.front; } // 3. 入队 void insert(queue *q, node x) { if((q->rear + 1)%MAX_SIZE == q->front) { printf("队列已满,无法入队!\n"); exit(1); } q->data[q->rear] = x; q->rear = (q->rear + 1)%MAX_SIZE; } // 4. 队列出队 node del(queue *q) { int front = q->front; if(q->rear == front) { printf("队列为空,无法出队!\n"); exit(1); } q->front = (front + 1)%MAX_SIZE; return q->data[front]; } // 5. 树的前序遍历 void preOrder(tree p) { if(p) { printf("%c ",p->data); for (int i = 0; i < m; i++) preOrder(p->child[i]); } } // 6. 树的后序遍历 void postOrder(tree p) { if(p) { for (int i = 0; i < m; i++) postOrder(p->child[i]); printf("%c ",p->data); } } // 7. 树的层序遍历 void leverOrder(tree t) { queue q; init(&q); if(t) // 树非空时 insert(&q,*t); // 队列初始为根结点 while (!empty(q)) // 当队列非空 { node n = del(&q); // 出队并访问 printf("%c ",n.data); for (int i = 0; i < m; ++i) { if(n.child[i]) insert(&q,*n.child[i]); // 每个结点的非空孩子入队 } } } // 8.按前序遍历顺序建立一棵度为3的树 tree creatTree() { char c; tree t; if((c = getchar()) == '#') t = NULL; else { t = (tree) malloc(sizeof(node)); t->data = c; for (int i = 0; i < m; ++i) t->child[i] = creatTree(); } return t; } int main() { tree root; // 声明一棵度为3的树 // AB###CE###FH###I####G###D###(样例) printf("创建一颗度为3的树,请输入结点,#表示空结点:\n"); root = creatTree(); printf("前序遍历为:\n"); preOrder(root); printf("\n后序遍历为:\n"); postOrder(root); printf("\n层序遍历为:\n"); leverOrder(root); return 0; }
2024年01月29日
47 阅读
0 评论
0 点赞
2024-01-29
树的存储结构
树的存储结构1.双亲表示法#define MAX_SIZE 100 typedef char dadaType; /** * 6.3 树的存储结构 * 1.双亲表示法 * 2.孩子表示法(指针方式孩子表示法;数组方式孩子表示法;链表方式孩子表示法) * 3.孩子兄弟表示法 */ // 6.3.1 双亲表示法 typedef struct node { dadaType data; int parent; }node; //双亲表示法的结点 typedef struct parentTree { node treeList[MAX_SIZE]; int root, length; // 根节点的位置及树结点个数 }tree; //双亲表示法的树 2.孩子表示法(指针方式孩子表示法;数组方式孩子表示法;链表方式孩子表示法)typedef char dadaType; // 6.3.2.1 指针方式孩子表示法 #define m 3 //树的度 typedef struct node { dadaType data; struct node *child[m]; // 指向孩子的指针数组 }node, *tree; tree root;#define MAX_SIZE 100 typedef char dadaType; // 6.3.2.2 数组方式孩子表示法 #define m 3 //树的度 typedef struct node { dadaType data; int child[m]; // 指向孩子的指针数组 }node; typedef struct tree { node treeList[MAX_SIZE]; int root, length; // 根节点的位置及树结点个数 }tree; #define MAX_SIZE 100 typedef char dadaType; // 6.3.2.3 链表方式孩子表示法 typedef struct chNode // 孩子结点类型(孩子链表) { int child; // 结点位置 struct chNode *next; }chNode,*chPoint; typedef struct node // 树中的结点类型 { dadaType data; chPoint firstChild; // 指向第一个孩子的指针 }node; typedef struct tree { node treeList[MAX_SIZE]; int root, length; // 根节点的位置及树结点个数 }tree; 3.孩子兄弟表示法typedef char dadaType; // 3.孩子兄弟表示法 typedef struct node // 树中每个结点类型 { dadaType data; struct node *firstChild, *rightSibling; }node, *tree; tree root;
2024年01月29日
60 阅读
0 评论
0 点赞
2024-01-29
递归的基本概念与递归程序设计以及常见的递归算法
递归的基本概念与递归程序设计以及常见的递归算法#include <stdio.h> // 1. 求n! int fact(int n) { if(n <= 1) return 1; return n * fact(n-1); } // 2.Fibonacci数列,前两项为1,第三项开始每项等于前两项的和 int fibonacci(int n) { if(n == 1 || n == 2) return 1; return fibonacci(n-1) + fibonacci(n-2); } // 3.打印数字三角形 void print(int n) { if(n > 0) { print(n-1); for (int i = 1; i <= n; ++i) printf("%d ",n); printf("\n"); } } // 4. 递归求数组的最大值 int max(int a[], int left, int right) { int lMax, rMax, mid; if(left == right) return a[left]; else { mid = (left+right)/2; lMax = max(a,left,mid); rMax = max(a,mid+1,right); return lMax > rMax ? lMax : rMax; } } int main() { int n = 5; printf("%d! = %d\n",n,fact(n)); printf("fibonacci数列的第%d项为%d\n",n,fibonacci(n)); print(5); int a[10] = {1,2,3,4,5,11,7,8,9,10}; printf("数组最大的数是:%d", max(a,0,9)); return 0; }
2024年01月29日
84 阅读
0 评论
0 点赞
1
2
3
4
...
12