//大根堆的构建、结点的插入和删除与此完全类似 #include<iostream> using namespace std; class MinHeap { public: int* heap;//存放小根堆中元素的数组 int maxHeapSize;//小根堆最多允许元素个数 int curr Read More
posted @ 2020-07-28 18:07
执着于风
Views(1254)
Comments(0)
Diggs(0)
#include<iostream> using namespace std; struct BinaryTreeNode{ int ltag,rtag; char data; BinaryTreeNode* leftChild; BinaryTreeNode* rightChild; Binary Read More
posted @ 2020-07-28 18:06
执着于风
Views(758)
Comments(0)
Diggs(0)
#include<iostream> using namespace std; struct BinaryTreeNode{ char data; BinaryTreeNode* leftChild; BinaryTreeNode* rightChild; BinaryTreeNode(char n Read More
posted @ 2020-07-28 18:03
执着于风
Views(572)
Comments(0)
Diggs(0)
#include<iostream> #define N 100 using namespace std; struct Graph{ int vertex_number; int edge_number; char vertex[N]; int edge[N][N]; }; Graph* G; i Read More
posted @ 2020-07-28 18:02
执着于风
Views(209)
Comments(0)
Diggs(0)
#include<iostream> #include<queue> #include<memory.h> #define maxSize 100 using namespace std; struct edgeNode { int dest; //邻接顶点的数组下标 //int weight; 权 Read More
posted @ 2020-07-28 18:00
执着于风
Views(374)
Comments(0)
Diggs(0)
#include <vector> using namespace std; #include<iostream> #include <cstdio> #include <cstring> #define maxn 200005 struct Edge { int v,next; }edge[max Read More
posted @ 2020-07-28 17:59
执着于风
Views(129)
Comments(0)
Diggs(0)
#include<iostream> using namespace std; void quick_sort(int array[], int start, int end) { if(start>=end) return; //递归终止条件 int i = start; int j = end; Read More
posted @ 2020-07-28 17:57
执着于风
Views(173)
Comments(0)
Diggs(0)
#include<iostream> #include<stdio.h> #define maxn 100 using namespace std; void merge(int arr[],low,mid,high){ int i,j,k; int n1=mid-low+1; int n2=hig Read More
posted @ 2020-07-28 17:56
执着于风
Views(99)
Comments(0)
Diggs(0)
#include<iostream> #include<stdio.h> #include<queue> using namespace std; int main() { priority_queue<int, vector<int>, greater<int> > minHeap; cout<< Read More
posted @ 2020-07-28 17:55
执着于风
Views(394)
Comments(0)
Diggs(0)
//vector建图,顶点是数字,本质是邻接表;二维数组建图,顶点是数字,本质是邻接矩阵 #include<iostream> #define maxn 100 //定义一个合适的值作为无边的标志 using namespace std; int main(){ int n,e,w,v1,v2;// Read More
posted @ 2020-07-28 17:54
执着于风
Views(425)
Comments(0)
Diggs(0)
#include<iostream> #include<queue> using namespace std; struct BSTNode{ int data; BSTNode *left,*right; BSTNode(int x,BSTNode* L=NULL,BSTNode* R=NULL) Read More
posted @ 2020-07-28 17:53
执着于风
Views(84)
Comments(0)
Diggs(0)
#include <iostream> #define maxn 1005 using namespace std; int fa[maxn]; void init() { for(int i=1;i<maxn;++i) { fa[i]=i; } } int find_ancestor(int x) Read More
posted @ 2020-07-28 17:51
执着于风
Views(76)
Comments(0)
Diggs(0)
#include<iostream> #include<cmath> using namespace std; int col[10],sum=0; //为了直观,行与列下标都从1开始,范围1-8,col[]数组中存的是每一行皇后位置的列值 void queen(int i){ //i表示当前行 i Read More
posted @ 2020-07-28 17:50
执着于风
Views(101)
Comments(0)
Diggs(0)
//vector建图,顶点是数字,本质是邻接表;二维数组建图,顶点是数字,本质是邻接矩阵 #include<iostream> #include<vector> using namespace std; const int N = 100; struct Edge{ int to,value; }e Read More
posted @ 2020-07-28 17:49
执着于风
Views(384)
Comments(0)
Diggs(0)
#include<iostream> #define INF 100 //找一个合适的值作为最大值,表示无边 using namespace std; int n=4; //顶点数 int G[4][4]={ {INF,1,3,5}, {1,INF,2,INF}, {3,2,INF,4}, {5,I Read More
posted @ 2020-07-28 17:48
执着于风
Views(109)
Comments(0)
Diggs(0)
#include<iostream> #include<algorithm> #define maxn 10005 using namespace std; int fa[maxn]; void init(){ for(int i=0;i<maxn;i++){ fa[i]=i; } } int ge Read More
posted @ 2020-07-28 17:47
执着于风
Views(104)
Comments(0)
Diggs(0)
#include <iostream> #include <string> using namespace std; //获取next数组 int* getNext(string T) { int len = T.size(); //获取T的长度 int* next = new int[len]; Read More
posted @ 2020-07-28 17:46
执着于风
Views(126)
Comments(0)
Diggs(0)
#include<iostream> #define INF 10000 //取合适的值作为无穷大表示无边 using namespace std; int n=7; //顶点数 int G[7][7]= { {INF,9,INF,INF,INF,INF,INF}, {9,INF,12,5,INF, Read More
posted @ 2020-07-28 17:44
执着于风
Views(121)
Comments(0)
Diggs(0)
#include<iostream> #include<string> using namespace std; int judge(string S,string T){ int i,j; int s_len=S.size(); int t_len=T.size(); for(i=0;i<=s_l Read More
posted @ 2020-07-28 17:42
执着于风
Views(100)
Comments(0)
Diggs(0)
//bf=右子树-左子树,删除时用左子树的中序最后一个结点填充 #include<iostream> #include<stack> #include<queue> using namespace std; struct Node{ int bf; int data; Node* left; Nod Read More
posted @ 2020-07-28 17:41
执着于风
Views(122)
Comments(0)
Diggs(0)
#include<iostream> #include<algorithm> using namespace std; struct Item{ int w,d; //w体积,d价值 }; Item items[3500]; int f[13000]; //j个空间的能装的最大价值f[j] int Read More
posted @ 2020-07-28 17:39
执着于风
Views(104)
Comments(0)
Diggs(0)

浙公网安备 33010602011771号