C语言
lihuaicheng17
菜鸟
展开
-
二叉树的叶子数量和深度
对于如图所示一个二叉树,求叶子数量和深度 #include <stdio.h> #include <stdlib.h> #include <string.h> struct BinaryNode { //数据域 char ch; //指针域 struct BinaryNode* lChild; struct BinaryNode* rChild; }; void calculateLeafNum(struct BinaryNode* root, in原创 2022-03-20 18:00:04 · 660 阅读 · 1 评论 -
栈的应用(就近匹配)
#include <stdio.h> #include <stdio.h> #include <string.h> #define MAX 1024 struct SStack { void* data[MAX]; int m_size; }; typedef void* SeqStack; //初始化栈 SeqStack init_SeqStack() { struct SStack* myStack = malloc(sizeof(struct SSta.原创 2022-03-19 11:27:23 · 344 阅读 · 0 评论 -
二叉树遍历(先序/中序/后续)
话不多说上代码 #include <stdio.h> #include <stdlib.h> #include <string.h> struct BinaryNode { //数据域 char ch; //指针域 struct BinaryNode* lChild; struct BinaryNode* rChild; }; //遍历 void recursion(struct BinaryNode* root) { if (root == NULL原创 2022-03-20 17:06:32 · 1416 阅读 · 0 评论