04 2022 档案
kmp
摘要:KMP算法分两步 一:求子字符串(p)的next数组 void getnext(int nextt[],string p) { nextt[0]=-1; for (int i=1;i<p.size();i++) { int j=nextt[i-1]; while ((p[j+1]!=p[i])&&(
动态链表
摘要:主要函数 1: malloc:函数原型 void *malloc(unsigned int size); 分配一个长度为size的连续空间,返回首地址。 空间不足时返回HULL; 2: calloc:函数原型 void *calloc(unsigned n,unsigned size) 分配n个长度
链表结构理解
摘要:#include <stdio.h> #include <malloc.h> struct node { int date; struct node *next; }; int main() { struct node a,b,c,*head,*p; a.date=1; b.date=2; c.da
逆序对
摘要:#include<iostream> #include<map> #include<queue> using namespace std; typedef long long ll; const int N=10000; int e[N]; int tmp[N]; ll merge_sort(int
map迭代器
摘要:#include<iostream>#include<map>#include<queue>using namespace std;queue<int> qu;map<int, int> mp;int sss(int a){for(auto it=mp.begin();it!=mp.end();it
快速排序map
摘要:map大数据时会超时 map有自动排序(降序:按first)和查重功能。 #include<iostream> #include<map> using namespace std; map<int, int> mp; void sss() { for(auto it=mp.begin();it!=m
向量与空间的解析几何
摘要:空间直角坐标系Oxyz:卦限 、坐标面xOy 、横、纵、竖坐标; 向量: 自由向量 、逆向量 、零向量 、方向角 、方向余弦 、 a*b:数量积 、向量积不同;平面向量的向量积垂直于平面(遵循右手法则); |c|=|a||b|sinθ; 三角形面积=|ab*ac|/2; 平面的点法式方程; 一般式方
归并排序
摘要:1 #include<stdio.h> 2 #include<iostream> 3 using namespace std; 4 int map[100]; 5 void merge_sort(int q[],int l,int r) 6 { 7 if(l>=r) 8 return; 9 int
spaf
摘要:#include<bits/stdc++.h> using namespace std;typedef long long ll;#define INF 0x3f3f3f3fconst ll N=610000;ll vis[21900]; //相当于bool函数ll dis[21900],u[N],
二叉树的构建
摘要:#include<iostream>#include<set>#include<algorithm>using namespace std;int tree[100];int create(int _tree[],int _node[],int len){ int i,max=1; _tree[1]
迭代器遍历 and auto遍历
摘要:迭代器 map<string,int>::iterator it; for(it=mp.begin();it!=mp.end();it++) { cout<<it->first<<" "<<it->second<<endl; } auto for(auto l:mp) { cout<<l.first