
算法与数据结构
Xia__Quan
这个作者很懒,什么都没留下…
展开
-
平衡二叉树(AVL树)
#include "stdlib.h"#include "stdio.h"#include using namespace std;typedef int data_type;typedef struct bst_node{ data_type data; struct bst_node * lchild, *rchild; }bst_t,*bst_p; static bst原创 2017-05-23 14:58:53 · 215 阅读 · 0 评论 -
C++ Vector容器
#include #include #include #include #include using namespace std; void myfunction(int i) { cout " " i;}void main() { vectorint> myvector; vectorint> myvector01; myvector.push_back(1原创 2017-06-27 17:51:06 · 196 阅读 · 0 评论 -
C++快速排序、归并排序
归并排序void Merge(int *a, int p, int q, int r) { int n1 = q-p+1; int n2 = r-q; int *L = new int[n1+1]; int *R = new int[n2+1]; int i, j, k; for (i=0转载 2017-06-22 17:53:45 · 315 阅读 · 0 评论 -
STL标准算法(二)排序算法和二分法搜索以及合并算法
排序Sorting:sort 按照某种条件,或者按正常 排序stable_sort 正常跑徐partial_sort 局部排序partial_sort_copy 局部排序nth_element 保证n在第n位,比它大的在后面,比它小的在前面,但不能保证是有序的二分法搜索Binary search (operating on sorted ranges):原创 2017-05-15 14:46:27 · 314 阅读 · 0 评论 -
STL标准算法(三)其它算法
Heap:push_heap pop_heap make_heap sort_heap 排序Min/max:min 得到最小值 max 得到最大值 min_element 得到最小值 max_element 得到最大值 lexicographical_compare 字母个数比较next_得到排列组合prev_permutation 得原创 2017-05-15 14:47:25 · 224 阅读 · 0 评论 -
STL标准算法(一)序列查找算法和序列修改算法
一、序列算法Non-modifying sequence operations:for_each 遍历输出参考C++函数手册.chm http://download.youkuaiyun.com/detail/u013866845/9841336find 查找一个元素在序列中是否存在find_if 查找一个符合条件的元素在序列中是否存在,find_end 一个序列的某个元素原创 2017-05-13 11:42:12 · 418 阅读 · 0 评论 -
C++ 选择排序、冒泡排序、插入排序
//sort.h#include "stdlib.h"#include "stdio.h"#include templatetypename T>class Sort { public: //void SelectSort(T* array, int size); void SelectSort(T*array, int size) { int temp原创 2017-05-24 11:23:38 · 277 阅读 · 0 评论 -
LinkList链表
#includeusing namespace std;struct Bean { string str; int id;}; struct Node {//需要有下一个节点的指针,需要一个bean存储这个节点的数据 Node* next; Bean bean; Node(Bean b) :bean(b),next(NULL) {} }; class LinkLis原创 2017-05-23 18:32:56 · 334 阅读 · 0 评论 -
递归
fibonacci序列 斐波那契数列(Fibonacci sequence)int fib(int n) { if(n==1) return (0); else if(n==2) return (1); else return (fib(n-2)+fib(n-1)); }原创 2017-06-23 09:24:08 · 195 阅读 · 0 评论