自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

chriselp

my workspace

  • 博客(64)
  • 资源 (2)
  • 收藏
  • 关注

原创 编译原理之标识符拆分

#pragma once#include#include#include using namespace std;const unordered_set keywords({ "auto", "short", "int", "long", "float", "double", "char", "struct", "union", "enum", "typedef", "const

2016-10-08 21:06:31 2165

原创 算法分析之半数集自底向上

#include#includeusing namespace std;int main(void){ int n; vector hset; hset.push_back(1); while (cin >> n) { if (hset.size() >= n + 1) cout << hset[n] << endl; else { for (int i

2016-10-08 11:34:10 692

原创 算法分析之有重复元素的排列问题O(n!)

#include#include#includeusing namespace std;templatevoid quicksort(vector& a, int left, int right, vector& next){ int L = left, R = right; eT T = a[L]; while (L < R) { while (a[R] >= T &&

2016-10-02 10:03:37 2491

原创 算法分析之众数问题O(nlogn)

#include#includeusing namespace std;int mode(vector& a, int left, int right, int& num) { int L = left, R = right; int T = a[L]; while (L < R) { while (a[R] >= T && L < R) --R; a[L] = a[R]

2016-10-02 09:04:12 3804

原创 C++实现红黑树建立,销毁,查找,插入和删除

/** RBT.h** Created on: Nov 30, 2015* Author: chris*/#pragma once#includeenum NodeColor{RED, BLACK};typedef int KeyType;struct RBTNode{ RBTNode *right, *left, *p; NodeColor colo

2015-12-01 09:10:14 763

原创 C++实现哈希表的创建,销毁,键值插入与删除

/** HashTable.h** Created on: Nov 19, 2015* Author: chris*/#pragma once#include const int numofsizes = 7;const int hashsize[] = { 11, 19, 31, 41, 53, 61, 71 };typedef int KeyType;

2015-12-01 09:05:20 4366

原创 C++实现B-树插入删除查找

/* * BMT.h * * Created on: Nov 2, 2015 * Author: chris */#ifndef BMT_H_#define BMT_H_#include#define m 3struct Record{ //empty.};typedef int KeyType;typedef struct BMTNode{

2015-11-15 15:19:51 1431 3

原创 C++实现二叉搜索树和AVL树

/* * BST.h * * Created on: Oct 31, 2015 * Author: chris */#ifndef BST_H_#define BST_H_#includetypedef int KeyType;struct ElemType{ int val; ElemType(): val(0) {}};typedef struc

2015-11-02 18:55:39 348

原创 C++实现图的十字链表表示及相关各算法

/* * OLGraph.h * * Created on: Oct 19, 2015 * Author: chris */#ifndef OLGRAPH_H_#define OLGRAPH_H_#include#include#define MAX_VERTEX_NUM 20#define INF INT_MAXstruct InfoType{ in

2015-10-31 19:45:45 964 1

原创 C++实现广义表及其遍历

/* * GList.h * * Created on: Oct 19, 2015 * Author: chris */#ifndef GLIST_H_#define GLIST_H_#includetypedef int AtomType;enum ElemTag{ATOM, LIST};struct GLNode{ ElemTag tag; uni

2015-10-19 20:45:20 656

原创 C++实现二叉树及其线索化和遍历

/* * BiTree.h * * Created on: Oct 17, 2015 * Author: chris */#ifndef BITREE_H_#define BITREE_H_#includetypedef int ElemType;struct BTNode { ElemType data; BTNode *lchild, *rchild

2015-10-18 11:18:04 581 1

原创 C++实现稀疏矩阵的十字链表表示法

/* * OLMat.h * * Created on: Oct 17, 2015 * Author: chris */#ifndef OLMAT_H_#define OLMAT_H_#includetypedef int ElemType;struct OLNode{ int i, j; ElemType e; OLNode *right, *dow

2015-10-17 20:13:06 1247

原创 C++实现KMP算法(优化版)

/* * Main.cpp * * Created on: Oct 7, 2015 * Author: chris */#include#include#includeusing namespace std;void get_next(const string pat, vector& next){ next.resize(pat.length(), 0

2015-10-07 18:15:09 397

原创 C++实现KMP算法(修正版,C++风格)

/* * Main.cpp * * Created on: Oct 7, 2015 * Author: chris */#include#include#includeusing namespace std;void get_next(const string pat, vector& next){ next.resize(pat.length(), 0

2015-10-07 17:54:36 432

原创 C++实现KMP算法(单值返回版)

/* * Main.cpp * * Created on: Oct 7, 2015 * Author: chris */#include#includeusing namespace std;bool get_next(const char* pat, int*& next){ int len = strlen(pat); next = new int[

2015-10-07 17:26:58 429

原创 C++实现KMP算法(C风格)

/* * Main.cpp * * Created on: Oct 7, 2015 * Author: chris */#include#includeusing namespace std;bool get_next(const char* pat, int*& next){ int len = strlen(pat); next = new int[

2015-10-07 17:05:52 367

原创 C++实现串的最小操作子集

/* * HString.h * * Created on: Oct 7, 2015 * Author: chris */#ifndef HSTRING_H_#define HSTRING_H_#includestruct HString{ int length; char *ch; HString(): length(0), ch(NULL) {}}

2015-10-07 15:58:22 1009

原创 C++实现离散事件模拟--Bank_Simulation

/** LkQueue.h** Created on: Oct 7, 2015* Author: chris*/#ifndef LKQUEUE_H_#define LKQUEUE_H_#includeusing namespace std;templatestruct LQNode{ ElemType data; LQNode * next; LQ

2015-10-07 11:51:31 1133

原创 C++实现链队列

/* * LkQueue.h * * Created on: Oct 7, 2015 * Author: chris */#ifndef LKQUEUE_H_#define LKQUEUE_H_typedef int ElemType;struct LQNode{ ElemType data; LQNode * next;};struct LkQueu

2015-10-07 09:36:18 367

原创 C++实现循环队列

/* * SqQueue.h * * Created on: Oct 7, 2015 * Author: chris */#ifndef SQQUEUE_H_#define SQQUEUE_H_typedef int ElemType;enum{SQQUEUEINITSIZE = 30};struct SqQueue{ ElemType * data;

2015-10-07 09:34:36 515

原创 C++实现顺序栈

/* * Stack.h * * Created on: Oct 6, 2015 * Author: chris */#ifndef SQSTACK_H_#define SQSTACK_H_typedef int ElemType;enum {STACKINITSIZE = 10, STACKINCSIZE = 10};struct SqStack{ El

2015-10-07 09:32:36 318

原创 C++实现链栈

/* * LkStack.h * * Created on: Oct 7, 2015 * Author: chris */#ifndef LKSTACK_H_#define LKSTACK_H_typedef int ElemType;struct LSNode{ ElemType data; LSNode * next;};struct LkSta

2015-10-07 09:30:30 398

原创 C++实现多项式操作及其加减乘除

/* * Polynomial.h * * Created on: Oct 6, 2015 * Author: chris */#ifndef POLYNOMIAL_H_#define POLYNOMIAL_H_#includestruct Term{ double coef; int exp; Term * next; Term():coef(0)

2015-10-06 23:40:51 8835

原创 C++实现双向链表

/* * DLList.h * * Created on: Oct 6, 2015 * Author: chris */#ifndef DLLIST_H_#define DLLIST_H_typedef int ElemType;typedef struct DLNode{ ElemType data; DLNode* prior; DLNode* nex

2015-10-06 19:25:31 382

原创 C++实现单链表

/* * LinkList.h * * Created on: Oct 6, 2015 * Author: chris */#ifndef LINKLIST_H_#define LINKLIST_H_typedef int ElemType;typedef struct SLNode { ElemType data; SLNode * next;}*SLL

2015-10-06 16:17:26 329

原创 C++实现线性表

/* * SqList.h * * Created on: Oct 6, 2015 * Author: chris */#ifndef SQLIST_H_#define SQLIST_H_#include#includetypedef int ElemType;enum {SQLISTINITSIZE = 10, SQLISTINCSIZE = 10};s

2015-10-06 12:26:37 403

原创 C++实现KMP模式匹配算法

#include#include#includeusing namespace std; void Next(const string & pat,vector & next){ next.resize(pat.length()); if(pat.length() == 0) return; next[0] = -1; for(size_t pos = 1; pos

2015-08-20 23:22:52 1003

转载 Kuhn_Munkres最大权匹配算法C++模板

#include #include #include // 使用其中的 min 函数using namespace std;const int MAX = 1024;int n; // X 的大小int weight [MAX] [MAX]; // X 到 Y 的映射(权重)int lx [MAX], ly [MAX]; // 标号bool sx [MAX], sy [MAX

2015-08-20 20:38:48 1100

原创 matlab实现基于DFS的Ford_Fulkerson最大流最小割算法

function [F, maxf, V, S] = Ford_Fulkerson(C, src, sink)n = size(C, 1);F = zeros(n);maxf = 0;V = [];S = [];while true % in: ResNet. ResNet = C - F + F'; % residual network. % ou

2015-08-15 11:21:55 4322 12

原创 C++实现Miller-Rabin素数测试

原理参见《离散数学》P201#include#include#include#includeusing namespace std;bool Miller_Rabin(long long n){ if(n < 2) return false; else if(n == 2) return true; long long q = 0, m = n - 1; w

2015-08-10 14:25:06 2122 3

原创 C++ 实现MST kruskal's algorithm

#include#include#include#include#includeusing namespace std;enum{ INF = INT_MAX };struct Edge{ int from; int to; int Wgt; Edge(int _from, int _to, int _Wgt = INF) : from(_from), to(_

2015-06-27 10:41:27 1169

转载 C++ 最大流(push-relable)算法

// The push-relable algorithm code due to CLRS chapter 26#include#includeusing namespace std;const int N = 100;int n; // vertex numberint e[N]; // residual flow of the vertexint h[N]; // height

2015-06-20 11:26:54 928

原创 C++ 基于Dijkstra算法和基于BFS算法的Ford Fulkson算法比较

#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = INT_MAX;//Edmond Karp.bool EK_bfs(vector > &G, int src, int dest, vector &Pr

2015-06-20 09:25:47 978

原创 C++ 基于Dijkstra最短路搜索的Ford Fulkson最大流算法

#include#include#include#include#includeusing namespace std;const int MAXN = 120;const int INF = INT_MAX;int G[MAXN][MAXN], N;int dist[MAXN], Pre[MAXN];bool visited[MAXN];int times = 0

2015-06-20 08:32:04 1086

原创 hdu oj 4300 Clairewd’s message AC code

#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;int main(void){ int T; cin >> T; while (T--) { string S, msg; while (cin >> S >> msg) { //assume d

2015-06-17 20:03:16 550

原创 C++实现Dijkstra算法

#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = INT_MAX;struct Node{ int pre; int d

2015-06-17 16:35:52 1423

原创 poj 3259 wormholes AC代码(负权环判断, Bellmanford)

#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 10001;struct Edge { int from; int to; int w

2015-06-17 14:34:30 587

原创 C++实现带路径记录的Floyd-Warshall算法

#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 100000000;void ch_status(vector > & W, vector > & P, int nNo

2015-06-06 21:41:02 1016

原创 C++实现floyd-warshall算法

#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 100000000;void ch_status(vector > & W, int nNodes) { //DP,

2015-06-06 21:22:14 1378

原创 C++实现Bellmanford算法

#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 100000000;struct Node{ int dist; int pre; Node() : dist(

2015-06-06 20:17:57 511

SmartPtr_Reference_Count

more effective c++ 中条款29的smart pointer 的实现代码

2015-06-01

the C book

一本比较老的书,比较罕见,十分难得的参考书

2014-12-07

空空如也

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

TA关注的人

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