- 博客(24)
- 收藏
- 关注
原创 c++引用注意事项
#include<iostream> using namespace std;//引用函数不能返回局部变量,否则使用一次后内存会删除//引用可以变成左值用来使用int& func(){ static int a = 20; return a;}void main(){ int& ref = func(); cout << ref << endl; func() = 100; cout << ref <&l.
2021-08-19 16:37:31
189
原创 c++new的使用
#include<iostream> using namespace std;//new返回的是 该类型数据的指针//在堆区创建整形的数据//释放内存用 deleteint* func(){ //int* P = new int(10); //return P; int *arr=new int[10]; for (int i = 0; i < 10; i++) { arr[i] = i; } for (int i = 0; i < 10; i++.
2021-08-19 16:18:42
91
原创 顺序查找和折半查找
#include<stdio.h>#define MAXSIZE 30typedef struct{ int key; char data;//其他数据类型 比如权值 }SeqList;int SeqSearch(SeqList r[], int n, int k){ int i = n; r[0].key = k;//哨兵 while (r[i].key!=k) { i--; } return i;}int BinSearch(SeqList r[], i.
2021-08-12 11:00:00
156
原创 DFS搜索树
#include<stdio.h>#include<stdlib.h>#define MAXSIZE 20typedef struct node{ int adjvex;//邻接点域 struct node* next;}EdgeNode;typedef struct vnode{ int vertax;//顶点域 EdgeNode* firstedge;}VertaxNode;void CreatAdjlist(VertaxNode g[], int .
2021-08-12 10:27:11
206
原创 建立无向图的邻接矩阵
#include<stdio.h>#include<stdlib.h>#define MAXSIZE 20typedef struct{ int vertax[MAXSIZE]; int edges[MAXSIZE][MAXSIZE];}MGraph;void CreatMGraph(MGraph* g, int e, int n)//建立邻接矩阵 n为顶点数,e为边数{ int i, j, k; printf("input data of vertaxs\n.
2021-08-12 09:35:48
2074
原创 中序线索化二叉树
#include<stdio.h>#include<stdlib.h> typedef struct node{ char data; int ltag, rtag; struct node* lchild; struct node* rchild;}TBTree;TBTree* pre;void Thread(TBTree* p)//对二叉树进行中序线索化{ if (p!=NULL) { Thread(p->lchild); if (p-&.
2021-08-11 21:23:57
129
原创 二叉树遍历的应用(求叶结点的数量和树的深度)
#include<stdio.h> #include<stdlib.h>#include <iostream>using namespace std;#define MAXSIZE 10typedef struct node{ char data; struct node* lchild, * rchild;}BSTree;void Preorder(BSTree* p){ if (p != NULL) { cout << p-.
2021-08-11 18:40:51
160
原创 二叉树的层次遍历
#include<stdio.h> #include<stdlib.h>#include <iostream>using namespace std;#define MAXSIZE 10typedef struct node{ char data; struct node* lchild, * rchild;}BSTree;typedef struct{ BSTree* data[MAXSIZE]; int rear, front;}SeQu.
2021-08-11 18:04:35
88
原创 两种非递归遍历二叉树方法
void Postorder(BSTree* p)//后序遍历{ BSTree* stack[MAXSIZE]; int i = 0,b[MAXSIZE]; stack[0] = NULL; while (p != NULL || i > 0) { if (p!=NULL) { stack[++i] = p; b[i] = 0; p = p->lchild; } else { p = stack[i--]; if (!b[i+1]).
2021-08-11 17:32:13
77
原创 二叉树的非递归遍历
#include<stdio.h>#include<stdlib.h>#define MAXSIZE 30typedef struct node{ char data; struct node* lchild, * rchild;}BSTree;void Preorder(BSTree* p)//先序遍历{ BSTree* stack[MAXSIZE]; int i = 0; stack[0] = NULL; while (p!=NULL||i>0).
2021-08-11 17:21:12
84
原创 算法:使用栈将队列逆置
#include <stdio.h> #include<stdlib.h>#define MAXSIZE 20typedef struct{ char data[MAXSIZE]; int top;}SeStack;void Init_Stack(SeStack **s){ *s = (SeStack *)malloc(sizeof(SeStack)); (*s)->top = -1;}int Empty_Stack(SeStack *s){ i.
2021-08-10 16:46:52
631
原创 顺序表的基本操作
#include<stdio.h>#include<stdlib.h>#define MAXSIZE 20typedef struct{ int data[MAXSIZE]; int len;}SeqList;SeqList *Init_SeqList()//顺序表的初始化{ SeqList *L; L = (SeqList *)malloc(sizeof(SeqList)); L->len = 0; return L;}void Creat.
2021-08-10 16:12:16
113
原创 链队列的基本操作
#include <stdio.h> #include<stdlib.h>typedef struct node{ char data; struct node *next;}QNode;typedef struct{ QNode *front, *rear;}LQueue;void Init_LQueue(LQueue **q){ QNode *p; *q = (LQueue*)malloc(sizeof(LQueue)); p = (QNode*.
2021-08-10 16:08:14
356
1
原创 python——turtle 实现樱花树
使用python中的turtle画一个很好看的樱花树,调用random和math话不多说,直接代码from turtle import *from random import *from math import *def tree(n,l): pd()#下笔 #阴影效果 t = cos(radians(heading()+45))/8+0.25 pencolor(t,t,t) pensize(n/3) forward(l)#画树枝
2021-07-10 18:10:49
1605
2
原创 python简易爬虫利用百度翻译制作自己的小翻译
本人作为刚学习几天的python 对爬虫非常的感兴趣 想用爬虫做一个翻译小东西,超级简单如果大家对爬虫也感兴趣,希望大家关注我,我会分享自己学习的爬虫过程,话不多说 直接上代码发现呢 百度翻译地址 采取的是一个动态的页面,我们叫需要找到地址的真实地址我们在百度翻译的网址:https://fanyi.baidu.com/?aldtype=16047#en/zh/当我们在聊天框输入想要查询的东西是呢,网址会给我们自动的跳出最后的结果,比如我们不需要点击上面,百度翻译页面会自己动的变化,.
2021-07-10 17:56:30
436
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人