自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(34)
  • 收藏
  • 关注

转载 Django 的快速入门教程

新手食用

2022-03-05 18:19:02 149

原创 C基础学习总结

一、数据存储原码:最高位为符号位,0为正,1为负。反码:正数不变;对于负数,符号位不变,其他取反。补码:正数不变;对于负数,取反码后加一。内存中都是补码。char:-128~127unsigned char:0~255二、地址和指针1.&:取地址(取首字节的地址)*地址:间接引用(地址不再额外占用空间)2.指针的本质:存地址的变量。如何声明指针变量:所指向的类型 + ∗*∗ + 变量名。如何判断变量的类型:去掉变量名,剩下的就是。指针大小:32位程序中,4个字节;64

2021-01-19 11:47:25 143

原创 排序算法总结笔记

排序名称最好的时间复杂度平均时间复杂度最坏时间复杂度空间复杂度是否稳定冒泡排序O(nnn) (已经有序的情况)O(n2n^2n2)O(n2n^2n2) (倒序)O(111)是选择排序O(n2n^2n2)O(n2n^2n2)O(n2n^2n2)O(111)否插入排序O(nnn) (已经有序的情况)O(n2n^2n2)O(n2n^2n2)(倒序)O(111)是快速排序O(nlog2nnlog_2nnlog2​n) (标准值左右等长)...

2020-09-26 13:32:13 166

原创 哈希查找

哈希查找散列表(Hash table,也叫哈希表),是根据键(Key)而直接访问在内存存储位置的数据结构。也就是说,它通过计算一个关于键值的函数,将所需查询的数据映射到表中一个位置来访问记录,这加快了查找速度。这个映射函数称做散列函数,存放记录的数组称做散列表。散列函数的规则是:通过某种转换关系,使关键字适度的分散到指定大小的的顺序结构中,越分散,则以后查找的时间复杂度越小,空间复杂度越高。具体的散列函数计算方法如下:直接定址法:取关键字或关键字的某个线性函数值为散列地址。即hash(k) = k

2020-09-25 18:59:16 421

原创 二分查找

二分查找查找:在一个非降序排列的数组Array中,查找一个元素key,如果找到返回这个元素对应的下标,否则返回-1。二分查找的思想是,先将key与序列的中位数比较Array[mid],如果相等则查找成功,如果key小则可知待查找值只可能在该中位数的左侧,因此在该中位数之前继续查找并同样采用取中位数的方式;反之相反的操作,不断循环。实现方法:循环或递归(增加了空间复杂度),代码如下。#include <stdio.h>#include <stdlib.h>//二分查找i

2020-09-25 18:32:03 122

原创 图的深度搜索DFS和广度搜索BFS

图的DFS和BFS实现方式:DFS:递归和标记数组BFS:队列和标记数组代码如下:#include <stdlib.h>#include <stdio.h>#include <string.h>typedef struct graph{ int nVertex; int nEdge; int* pMatrix;}Graph;Graph *CreateGraph(){ Graph *pGraph = NULL; pGraph = (G

2020-08-28 16:03:57 77

原创 图的基本创建

基于c采用邻接矩阵构建一个无向图,代码如下:#include <stdlib.h>#include <stdio.h>#include <string.h>typedef struct graph{ int nVertex; int nEdge; int* pMatrix;}Graph;Graph *CreateGraph(){ Graph *pGraph = NULL; pGraph = (Graph*)malloc(sizeof(Grap

2020-08-28 15:59:53 339

原创 红黑树RBT基本概念与实现

1. 基本概念RBT的作用与平衡二叉树类似,目的是优化原始BST查找效率低的问题。RBT需成立,要满足如下条件:树中每个节点有颜色(红或黑)根节点必须为黑色NULL值处称为终端节点,我们可以认为是黑色不允许两个红节点互为父子关系从任意节点向下出发,到所有终端节点的各条路径上黑节点个数相同2. RBT节点添加向RBT添加节点,该节点默认初始化为红色。(若为黑色则第五个条件不满足,若为红色可能不满足第四个条件,但第五个条件不好调控,所以选择红色。)添加步骤如下图:3. RBT节点删除

2020-08-28 15:55:20 691

原创 二叉树的旋转操作

二叉树的旋转操作是针对AVL平衡二叉树或RBT红黑树而言的,当发现树不平衡时,使用旋转操作。旋转分为3类:左旋右旋双旋转:LR , RL代码:#include <stdlib.h>#include <stdio.h>typedef struct tree{ int nValue; struct tree *pLeft; struct tree *pRight; struct tree *pFat;}BinaryTree;BinaryTree *C

2020-08-27 16:25:10 777

原创 排序二叉树BST转双向链表

基于c实现排序二叉树转为双向链表,无需重新再创建一个双向链表结构体,直接对树的指针操作。代码:#include <stdlib.h>#include <stdio.h>typedef struct tree{ int nValue; struct tree *pLeft; struct tree *pRight;}BST;void AddNode(BST **pTree, int num){ BST *pTemp = (BST*)malloc(sizeof

2020-08-27 15:55:27 196

原创 排序二叉树BST的基本操作

基于C语言实现排序二叉树BST基本操作,具体包括:增加节点创建BST删除节点#include <stdlib.h>#include <stdio.h>typedef struct tree{ int nValue; struct tree *pLeft; struct tree *pRight;}BST;//增加节点void AddNode(BST **pTree, int num){ BST *pTemp = (BST*)malloc(sizeo

2020-08-27 15:16:49 201

原创 二叉树层序遍历

基于c实现二叉树的层序遍历,借助队列实现。代码(gcc):#include <stdlib.h>#include <stdio.h>typedef struct tree{ int nValue; struct tree *pLeft; struct tree *pRight;}BinaryTree;typedef struct node{ BinaryTree *pTree; struct node *pNext;}Node;typedef str

2020-08-27 15:08:21 120

原创 二叉树的非递归遍历

基于c实现二叉树的前、中、后序非递归遍历。代码如下(gcc):#include <stdlib.h>#include <stdio.h>typedef struct tree{ int nValue; struct tree *pLeft; struct tree *pRight;}BinaryTree;typedef struct node{ BinaryTree *pTree; struct node *pNext;}Node;typedef s

2020-08-27 15:04:21 87

原创 二叉树的创建

基于c实现的二叉树创建,其中包括:手动创建二叉树前、中、后序遍历二叉树前序创建二叉树利用数组构建完全二叉树代码如下(gcc):#include <stdlib.h>#include <stdio.h>typedef struct tree{ int nValue; struct tree *pLeft; struct tree *pRight;}BinaryTree;//手动创建二叉树BinaryTree *CreateBinaryTree(){

2020-08-27 15:00:45 139

原创 队列实现栈的功能

基于C完成两队列来实现栈的功能,核心思想为:设置两个队列,为保证先进后出,将有元素队列中元素出队直到剩一个元素(此时另一个队列为空),出队元素全部入队到另一个队列。之后将剩一个元素的队列出队,完成栈的出栈操作。入栈操作只要保证都入到有元素的队列中即可。实现代码如下(gcc):#include <stdlib.h>#include <stdio.h>typedef struct node{ int nValue; struct node *pNext;}Node;

2020-08-26 19:53:57 140

原创 利用栈实现队列功能

栈的功能的总结:递归的实现是基于栈的四则运算表达式从中缀表达式转为后缀表达式(系统内部实现)。(1)借助辅助栈。(2)遇到数字直接打印。(3)遇到符号,将当前符号与栈顶元素进行优先级比较,如果当前元素优先级高直接入栈,若当前元素优先级低则将栈内元素出栈,直到比栈内元素高为止。(4)遇到左括号无条件入栈,遇右括号栈内依次出栈直到左括号停止。从后缀转为中缀表达式。(1)借助辅助栈。(2)遇到数字入栈。(3)遇符号将栈顶元素下一个和栈顶元素构成表达式。使用两个栈完成队列的功能:一个作为入栈,一个

2020-08-26 19:42:45 337

原创 队列基本操作

基于c语言实现的队列基本操作,包括:创建入队出队判断是否为空代码如下(gcc编译器):#include <stdlib.h>#include <stdio.h>typedef struct node{ int nValue; struct node *pNext;}Node;typedef struct queue{ int nCount; Node *pHead; Node *pTail;}Queue;void Init(Queue

2020-08-26 17:23:19 98

原创 斐波那契与递归

实现斐波那契可分为递归和非递归的方式,递归方法即浪费空间也耗费时间,不推荐使用。代码如下(gcc编译器):#include <stdlib.h>#include <stdio.h>unsigned int fibonaci(int num){ //递归 if(num == 1|| num == 2 ) return 1; return fibonaci(num-1)+fibonaci(num-2);}unsigned int fibonaci_2(int n

2020-08-26 17:19:30 142

原创 栈基本操作

基于c语言实现的栈基本操作,包括:创建入栈出栈清空销毁得到栈内元素个数得到栈顶元素判断栈是否为空代码如下(gcc编译器):#include <stdio.h>#include <stdlib.h>typedef struct node{ int nValue; struct node *pNext;}Node;typedef struct stack{ Node *pTop; int Count;}Stack;void Init(S

2020-08-26 17:13:02 95

原创 链表基本操作

链表基本操作基于c实现的链表基本操作,方法包括:链表创建:利用尾插法实现链表顺序遍历链表逆序遍历:递归实现链表原地倒置头插法:采用链表添加时的头插法思想三指针平移法:前两个指针用于改变链表指向,后一个指针记录下一节点位置,每一次操作完向后平移一个节点。代码如下(gcc编译器),#include <stdlib.h>#include <stdio.h>typedef struct list{ int nValue; struct list *pN

2020-08-26 17:04:10 120

原创 已知递增单链表A和B,求集合A和集合B的差集,保存在链表A中

算法思想:只需将链表A中共有的节点删除即可。定义指针p,q分别指向A,B的头结点,当A中元素小于B的时,p右移一位(B类似操作),值相等时,删除该节点,任一指针为空时停止循环代码:#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;using namespace std;typede...

2020-06-02 21:31:24 1158

原创 Qt5制作鼠标悬停显示相应信息的ToolTip

来到这里小伙伴,应该已经知道它是干什么的吧,相当于当你指向图标时,给出你一些简要的提示信息。网上有类似资源,但可能无法立即执行,新入门的伙伴可以看看我的代码哈。ctooltip.h#ifndef CTOOLTIP_H#define CTOOLTIP_H#include <QWidget>#include <QLabel>#include <QPu...

2019-04-28 10:55:13 11628

原创 二叉树从根到叶节点的每条路径

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 10using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild;}BTNode;voi...

2018-08-17 21:41:10 698 3

原创 求二叉树中值为x的节点的层号

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 20using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild;}BTNode;typ...

2018-08-16 21:27:42 4071

原创 满二叉树先序变中序

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 10using namespace std;void change(int pre[],int l1,int r1,int *post,int l2,int r2){ if(l1&lt;=r1) ...

2018-08-16 20:33:59 410 1

原创 增加指向双亲节点的指针parent,输出所有节点到根节点路径

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 10using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild; BTN...

2018-08-16 19:45:55 1089 1

原创 二叉树节点操作

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 10using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild;}BTNode;voi...

2018-08-16 19:14:06 194

原创 二叉树先,中,后序非递归遍历

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 10using namespace std;typedef struct BTNode{ char data; struct BTNode *lchild; struct BTNode *rch...

2018-08-11 20:12:10 113

原创 循环队列加入tag使front==rear用做队满条件

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 100using namespace std;typedef struct { int data[maxsize]; int front,rear; int tag;}squeue;int ...

2018-08-02 20:45:39 2973 2

转载 循环队列两端都可进行插入删除 (队尾删除,对头插入)

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 100using namespace std;typedef struct { int data[maxsize]; int front,rear;}squeue;int desqueue(sq...

2018-08-02 20:25:32 6456

原创 用带头节点的循环链表表示队列

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;using namespace std;typedef struct LNode{ int data; struct LNode *next;}LNode;void enqueue(LNode *&amp;rear,int x)...

2018-08-02 19:27:47 1945

原创 用两个栈完成队列入队,出队,判空

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 100using namespace std;typedef struct{ int elem[maxsize]; int top;}Sqstack;int Isempty(Sqsta...

2018-07-30 20:18:46 707

原创 求后缀式数值

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 100using namespace std;int OP(int a,char op,int b){ if(op=='+') return a+b; if(op=='-') return...

2018-07-29 19:41:47 354

原创 小括号的匹配

#include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#define maxsize 100using namespace std;int match(char A[],int n){ char stack[maxsize]; int count=0,top=-1,i; ...

2018-07-28 21:38:04 693

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除