11 2018 档案
摘要:一、先序 1.方法一 2.方法二 二、中序 三、后序 四、范例 #include<iostream> #include<string> #include<stack> using namespace std; const int max_size=100; struct Btnode { char
阅读全文
摘要:一、先序 二、中序 三、后序 四、层次 五、试例 #include<iostream> #include<string> using namespace std; const int max_size=100; struct Btnode { char data; Btnode *lchild; B
阅读全文
摘要:1.目的:当函数较短并频繁使用时,使用内联函数可以减少时间开销 2.格式 在函数定义前面加“inline”关键字,即定义了内联函数 如下:
阅读全文
摘要:一、引用 1. 引用格式 a.类型名 & 变量名 =另一个变量 b.试例: 2.常引用 二、常量 1.基本用法:const int n=12; 2.常量指针:const int *p=&n; p不可用于修改n,除此之外,p指向的对象可以再次更改 试例: 3.函数 参数指针
阅读全文
摘要:一、双亲存储结构 二、孩子链存储结构 typedef struct snode{ int data; node *next;//指向兄弟; }Son_node;typedef struct{ int data; int parent; Son_node *first_son;}Pnode;//双亲节
阅读全文
摘要:一、括号表示法建二叉树 核心代码 void make_Btree() { Btnode *st[max_size],*p; string str; int k,j=0,top=-1; b=NULL; cin>>str; for(int i=0;i<str.size();i++) { switch(s
阅读全文
摘要:一、cin重载 1.cin为ostream类的成员 2.cin重载应为全局函数(毕竟ostream是别人写好的) 3.代码 a.核心代码 b.完整试例 二、cout重载 1.核心代码 2.完整试例
阅读全文
摘要:1.核心代码 class Kmp { public : string s; string t; int next[maxn]; void get_next() { int i=-1,j=0,lent=t.size(); next[j]=-1; while(j<lent-1) { if(i 1||t[
阅读全文
摘要:一、this指针 this指向本身作用的对象 二、友元 friend 1.友元函数:一个类的友元函数可以访问该类的私有成员 (友元可以是普通全局函数,也可以是别的类 的成员函数) 2.友元类:该友元类所有函数有权访问 类的所有私有成员
阅读全文
摘要:注意:下标必须是人物编号,且从1—INF 1.核心代码: #include<iostream> using namespace std; const int maxn=1000; class Ufstree { struct node { int data; int rank; int par;//
阅读全文
摘要:对象:有向图(有无权无所谓) 存储方式:邻接表(最好写罢了,空间也比较少) 核心代码: void topsort(adjgraph g) { int i,j; int visited[maxn]={0}; int st[maxn],top=-1; arcnode *p; for(int i=0;i<
阅读全文
摘要:适应对象:有权图(有向或无向都行) 图存储方式:邻接矩阵(有0和INF的那种,否则就over) 一、Floyd算法: 1。核心代码: void floyd() { int i,j,k; for(i=0;i<g.n;i++) for(j=0;j<g.n;j++) { dist[i][j]=g.edge
阅读全文
摘要:对象:无权图,可不连通 一、DFS 1. 邻接矩阵 a.核心代码: b.例题地址:http://120.77.243.165/problem.php?id=3956 #include<iostream> using namespace std; const int maxn=100; class G
阅读全文
摘要:矩阵: 邻接表: struct arcnode { int adjvex; int weight; arcnode *nextarc; }; struct vnode { int info; arcnode *firstarc; }; struct adjgraph { vnode adjlist[
阅读全文
摘要:对象:有权无向图(带权连通图) 图的存储:邻接矩阵且有0和INF的那种 or 邻接表。 矩阵实现: #include<iostream> using namespace std; const int maxn=100; class graph { struct gra { int n;//verte
阅读全文
摘要:Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1. map最基本的构造函数 2. map添加数据 3. map中元素的查找 4,map中元素的删除 5,map中 swap的用法: 6.map的sort问题
阅读全文

浙公网安备 33010602011771号