- 博客(9)
- 资源 (2)
- 收藏
- 关注
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 数据结构 顺序表—插入 删除 最大值
考研笔记 数据结构代码 本人小白一个,考研的科目是数据结构 就用此博客来记录练习的代码。借鉴了别人的很多地方和天勤书上的内容。 顺序表 构建一个顺序表 实现以一下功能 1.找出最大值 2.正序输出 3.插入一个元素 4.删除一个元素 5.逆序输出 #include<stdio.h> #include<iostream> #define maxSize 100 #define ERROR 0; using namespace std; typedef struct{
2020-07-12 21:21:15
3172
原创 计算二叉树的深度(递归)
二叉树的深度(递归) 思想: 1.如果为空树,返回0; 2.如果不是空树 (1)递归计算左子树的深度,记为m (2)递归计算右子树的深度,记为n 若m>n, 返回m+1 否则返回n+1 int depth(BiTree T) { if(T == NULL) return 0; else { m = depth(T -> lchild); n = depth(T -> rchild); if(m
2020-11-30 22:26:16
7823
5
原创 BF算法
BF //BF算法 int BF_index(sstring S, sstring T, int pos) { i=pos; j=1; while(i < S.length && j < T.length) { if(ch[i] == ch[j]) // i与j匹配 就后移 { ++i; ++j; } else {
2020-11-29 22:48:10
347
原创 括号匹配片段 栈实现
括号匹配(栈) // 括号匹配 stasus Matching() { Initstack(s); flag = 1; cin >> ch; while(ch != '#'&&flag) { switch() { case '('; case '['; push(s,ch); break; case ')';
2020-11-29 22:33:48
91
原创 数制转换 栈实现
数制转换(伪代码) //数制转换 void convers(int N) { initstack(s); while(N) { push(s,N%8); //八进制 N = N/8; } while(!stackEmpty(s)) { pop(s,e); cout << e; } }
2020-11-29 22:20:03
293
原创 双重递归函数
插曲——递归函数 这个问题困扰了我半天 觉都没睡好 先上 代码 思想我整理一下 再描述 #include <stdio.h> void co(int a) { a++; if(a<4) { co(a); co(a); } printf("%d\n",a); } int main(int argc, char*argv[]) { int a = 0; co(a); return 0; } 输出
2020-07-16 10:31:49
755
原创 数据结构 线性表—表逆置
线性表问题—逆置 其余有难度的真题等我二刷代码的时候继续更新 现在先了解思想。持续关注我每天更新考研代码 思想: 表逆置问题是个重要的考点 设置两个整型变量 i 和 j,i 指向第一个元素,j 指向最后一个元素,设置一个中间变量temp,边交换i 和 j 所指元素,并将i 和 j 相向而行。 代码片段和过程如下 for (int i = left, j = right; i < j , ++i , --j) { temp = a[i]; a[i] = a[j]; a[j] = temp; }
2020-07-15 20:59:30
2379
原创 数据结构 链表—尾插法 头插法
链表建表算法代码——尾插法、头插法 题中默认的一般为为带头结点的。 尾插法 需要申请两个结点 int createLinkListR(LNode*&c,int a[], int n)//要改变的变量用引用型 { c = (LNode*)malloc(sizeof(LNode)); //申请c的头结点空间 c->next = NULL; LNode *p,*s int i; s=c; for(i =0; i < n; ++i) { p = (LNode*)malloc(
2020-07-14 21:17:34
297
1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人