自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(164)
  • 资源 (1)
  • 收藏
  • 关注

原创 【查找】二分查找、插值查找、斐波那契查找

#includeusing namespace std;int binary_search(int* data, int n, int key){ int low, high, mid; low = 0; high = n-1; while (low <= high){ mid = low + (high - low) / 2; if (key < data[mid])

2016-05-29 19:33:09 580

原创 【排序】桶排序

#includeusing namespace std;typedef struct node{ int key; struct node* next; node(int k) :key(k), next(NULL){}}node;void bucket_sort(int nums[],int len,int bucket_size){ node** bucket_table

2016-05-14 14:00:56 404

原创 【排序】基数排序

#includeusing namespace std;//求数据的最大位数int get_max_bit(int nums[], int len){ int count; int max = 1; int* temp = new int[len]; for (int i = 0; i < len; i++) temp[i] = nums[i]

2016-05-14 13:54:13 378

原创 【排序】快速排序

#includeusing namespace std;int pnumsrtition(int nums[], int low, int high){ int pivot_key = nums[low];//用区间的第1个记录作为基准 while (low < high){//从区间两端交替向中间扫描,直到low=high为止 while (low = pi

2016-05-14 13:49:08 350

原创 【排序】归并排序(递归和非递归版本)

#includeusing namespace std;void merge(int* a, int* temp, int begin, int middle, int end){ int i = begin; int j = middle + 1; int k = 0; while (i <= middle&&j <= end){//比较两个指针所指向的元素,选择相对小的元素放入到

2016-05-14 13:47:36 2393

原创 【排序】堆排序

MyHeap.h#ifndef MY_HEAP_H #define MY_HEAP_H #include #include #define max_value -99999999 //仿函数 templatestruct MyLess{ bool operator()(const T& x, const T& y) const { return x < y

2016-05-14 13:44:04 294

原创 【排序】冒泡排序、选择排序、插入排序、希尔排序

#includeusing namespace std;void swap(int* a, int* b){ int temp = *a; *a = *b; *b = temp;}void bubble_sort1(int nums[],int len){ for (int i = 0; i < len; i++){ for (int j = len - 1; j>i; j

2016-05-14 13:38:51 313

原创 【图】拓扑排序

#include#include#includeusing namespace std;class Hdu3342{public: void initial(int n, int m); void read_case(); bool topological_sort(); void print_result();private: vector vec[101];//节点的邻

2016-04-10 15:28:41 336

原创 【图】最短路径Bellman-Ford算法

#includeusing namespace std;const int max_num = 500;const int max_len = 10000;typedef struct Edge{ int begin;//起点 int end;//终点 int weight;//权值 }Edge;class BellmanFord{public:

2016-04-04 22:39:47 710

原创 【图】最短路径Dijkstra算法和Floyd算法

一、Dijkstra算法#includeusing namespace std;const int maxint = 10000;class Dij{public: void initial(int m, int n); void read_case(); void dijkstra(int begin, int end); void search_path(int begi

2016-03-30 19:46:53 778

原创 【图】最小生成树Prim算法和Kruskal算法

一、Prim算法#includeusing namespace std;const int max = 10000;class Hdu1233{public: void initial(int n); void read_case(); void prim(); void print_result();private: int path[101][101]; int d

2016-03-23 20:42:48 450

原创 【图】BFS和DFS

一、BFS#include#includeusing namespace std;const int max_num = 100;class BFS{public: typedef int VertexType; typedef int EdgeType; BFS(); void create_graph(); void bfs_traverse();private:

2016-03-15 20:18:15 323

原创 【图】邻接矩阵和邻接表

#includeusing namespace std;class AdjacencyMatrix{public: typedef int VertexType; typedef int EdgeType; AdjacencyMatrix(); ~AdjacencyMatrix(); void create_graph(); void print_graph();privat

2016-03-07 20:30:19 582

原创 【树】Trie树

#include#includeusing namespace std;//Trie树结点struct TrieNode{ bool is_string;//标记该结点处是否构成单词 TrieNode* next[26]; TrieNode() :is_string(false){ for (int i = 0; i < 26; i++) next[i] = NULL;

2016-02-23 16:10:54 284

原创 【树】二叉排序树

BinarySortTree.h#ifndef BINARYSORTTREE_H#define BINARYSORTTREE_H#include//binary sort tree nodestruct binary_sort_tree_node{ int data; binary_sort_tree_node* lchild; binary_sort_tree_node* rc

2016-01-18 18:45:35 473

原创 【树】哈弗曼树和哈弗曼编码

#include#includeusing namespace std;const int max_size = 50;struct HuffmanNode{ int weight;//weight表示权值数据域 int parent;//par=0表明结点是独立的,par>0为它的双亲下标 int lchild, rchild;//lchild, rchild为左

2016-01-13 16:37:08 447

原创 【树】已知二叉树前序和中序遍历求后序遍历,及中序和后序遍历求前序遍历

#includeusing namespace std;//已知二叉树前序遍历和中序遍历,求后序遍历void binary_tree_postorder(char* preorder,char* inorder,int length){ if (length == 0) return; char root = *preorder; int index = 0; for (; in

2016-01-11 13:30:00 744

原创 【树】二叉树的各种操作

BinaryTree.h#ifndef BINARYTREE_H#define BINARYTREE_H#include#include#include//binary tree nodestruct binary_tree_node{ char data; binary_tree_node* lchild; binary_tree_node* rchild; binar

2015-12-13 18:44:55 399

原创 【String】引用计数实现String

String.h#ifndef STRING_H#define STRING_H#define _CRT_SECURE_NO_WARNINGS#include//Stringclass String{public: String(const char* str = NULL);//constructor String(const String& rhs);//copy cons

2015-11-29 20:45:44 713 1

原创 【栈,队列】两队列实现栈

一、用STL的queue实现MyStack.h#ifndef MYSTACK_H#define MYSTACK_H#include#include//MyStacktemplateclass MyStack{public: typedef T value_type; typedef T& reference; MyStack();//constructor ~MyS

2015-11-21 15:17:25 434

原创 【栈,队列】两栈实现队列

一、用STL中的stack实现MyQueue.h#ifndef MYQUEUE_H#define MYQUEUE_h#include#include//MyQueuetemplateclass MyQueue{public: typedef T value_type; typedef T& reference; MyQueue();//constructor ~My

2015-11-15 14:00:12 303

原创 【栈】两栈共享空间

SeqDoubleStack.h#ifndef SEQDOUBLESTACK_H#define SEQDOUBLESTACK_H#includeint default_size = 20;// SeqDoubleStacktemplateclass SeqDoubleStack{public: typedef T& reference; SeqDoubleStack(int

2015-11-15 10:38:22 343

原创 【队列】链式队列

LinkedQueue.h#ifndef LINKEDQUEUE_H#define LINKEDQUEUE_h#include//queue nodetemplatestruct queue_node{ typedef queue_node* pointer; T data; pointer next; queue_node() :next(NULL){} queue_n

2015-11-14 13:57:13 338

原创 【队列】循环队列

CircularQueue.h#ifndef CIRCULARQUEUE_H#define CIRCULARQUEUE_Hint default_size = 10;#include//CircularQueuetemplateclass CircularQueue{public: typedef T& reference; CircularQueue(int size

2015-11-14 10:36:38 313

原创 【栈】链式栈

LinkedStack.h#ifndef LINKEDSTACK_H#define LINKEDSTACK_H#include//Stack nodetemplatestruct stack_node{ typedef stack_node* pointer; T data; pointer next; stack_node() :next(NULL){} stack_n

2015-11-11 21:48:46 295

原创 【栈】顺序栈

SeqStack.h#ifndef SEQSTACK_H#define SEQSTACK_H#includeint default_size = 20;// SeqStacktemplateclass SeqStack{public: typedef T& reference; SeqStack(int size = default_size);//constructor

2015-11-11 21:38:39 310

原创 【线性表】静态链表

StaticLinkedList.h#ifndef STATICLINKEDLIST_H#define STATICLINKEDLIST_H#includeconst int max_size = 1000;//list nodetemplatestruct list_node{ T data; int cur;//cursor};//StaticLinkedList

2015-11-08 20:52:32 340

原创 【线性表】双向循环链表

DualCirculationList.h#ifndef DUALCIRCULATIONLIST_H#define DUALCIRCULATIONLIST_H#include//list nodetemplatestruct list_node{ typedef list_node* pointer; T data; pointer prior; p

2015-11-08 18:38:46 316

原创 【线性表】单链表

SingleLinkedList.h#ifndef SINGLELINKEDLIST_H#define SINGLELINKEDLIST_H#include//list nodetemplatestruct list_node{ typedef list_node* pointer; T data; pointer next; list_node() :next(NULL)

2015-11-08 14:16:25 304

原创 【线性表】顺序表

SeqList.h#ifndef SEQLIST_H#define SEQLIST_H#includeconst int default_size = 100;//SeqListtemplateclass SeqList{public: typedef T value_type; typedef T* pointer; SeqList(int size = defaul

2015-11-07 15:07:22 321

原创 【c++ templates读书笔记】【7】模板元编程

模板实例化机制是一种基本的递归语言机制,可以用于在编译期执行复杂的计算。这种随着模板实例化所出现的编译器计算通常被称为template metaprogramming。例子一,计算阶乘://Pow.h#ifndef POW_H#define POW_Htemplateclass Pow{public: enum { result = M*Pow::result };};

2015-10-16 15:33:00 346

原创 我的~/.vimrc设置

~/.vimrc设置"-------------------------Basic Configuration Begin-------------------------""Support Chinese when logging in by sshset fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936set termenco

2015-10-10 21:24:27 743

原创 【c++ templates读书笔记】【6】模板的多态

C++中的多态分为动多态和静多态。动多态是通过继承和虚函数来实现的,这两个机制都是在运行期进行处理的。平常所谈论的C++多态指的就是这种动多态。模板也允许使用单一的泛型标记来关联不同的特定行为,这种借助于模板的关联是在编译器进行处理的,因此把这种多态称为静多态。一、动多态动多态的设计思想主要在于:对于几个相关对象的类型,确定它们之间的一个共同功能集,然后在基类中,把这些共同的功

2015-10-08 18:32:41 319

转载 将Vim改造为强大的IDE—Vim集成Ctags/Taglist/Cscope/Winmanager/NERDTree/OmniCppComplete(有图有真相)

转自http://blog.csdn.net/bokee/article/details/6633193工欲善其事,必先利其器。一个强大的开发环境可以大大提高工作效率。好吧,我知道这是废话。。。不过,我想一定有很多跟我一样打算进入Linux平台开发的新手,一开始都为找不到一个像Windows下的VS那样可以一键安装并且功能几乎完美无缺的开发工具而郁闷不已,甚至打算收回刚刚迈出的脚步。所幸的

2015-10-05 20:57:21 349

转载 手把手教你把Vim改装成一个IDE编程环境(图文)

手把手教你把Vim改装成一个IDE编程环境(图文)By:吴垠Date:2007-09-07Version:0.5Email:lazy.fox.wu#gmail.comHomepage:http://blog.csdn.net/wooinCopyright:该文章版权由吴垠和他可爱的老婆小包子所有

2015-10-05 20:50:09 379

原创 【c++ templates读书笔记】【5】模板实战

1、模板声明和模板定义如果不在同一个文件中,在另一个文件中使用模板时会出现链接错误。例子://Myfirst.h#ifndef MYFIRST_H#define MYFIRST_H#include#includeusing namespace std;templatevoid print_typeof(T const& x);#endif//Myfirst.cpp

2015-09-30 17:03:46 313

原创 【c++ templates读书笔记】【4】技巧性基础知识

1、关键字typename引入关键字typename是为了说明:模板内部的标识符可以是一个类型。当某个依赖与模板参数的名称是一个类型时,就应该使用typename。templateclass MyClass{ typename T::SubType * ptr; // typename说明SubType是定义于T内的一种类型,如果不使用typename,SubType会被认为是T的一

2015-09-27 13:36:54 321

原创 【c++ templates读书笔记】【3】非类型模板参数

对于函数模板和类模板,模板参数并不局限于类型,普通值也可以作为模板参数。但非类型模板参数是有限制的,只能是常整数(包括枚举值)或者指向外部链接对象的指针,浮点数、类对象和内部链接对象不允许作为非类型模板参数的。1、非类型类模板参数例子#includeusing namespace std;//Maxsize是一个非类型模板参数templateclass Stack{private

2015-09-26 13:35:45 380

原创 【c++ templates读书笔记】【2】类模板

1、类模板的声明template class Stack{ ...}2、在类模板内部,T可以像其他任何类型一样,用于声明成员变量和成员函数。template class Stack{private: std::vector elemes; // 存储元素的容器public: Stack(); // 构造函数 voi

2015-09-23 19:26:32 331

原创 【c++ templates读书笔记】【1】函数模板

1、定义函数模板:templateinline T const& max (T const& a, T const& b){ return a < b ? b : a;}解释:template表明了这是一个函数模板,指定了模板参数区域,typename表明了后面的参数是一个类型名, T是模板参数,它可以用来指定所有的类型,a和b是调用参数,位于模板函数名称后面,在一对()内进行声

2015-09-19 14:08:57 538

DOS教程.rar

DOS命令,教你怎么使用dos命令。在汇编中要学到,所以就上传了,方便大家学习

2012-09-21

空空如也

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

TA关注的人

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