![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
传奇代码搬运工
这个作者很懒,什么都没留下…
展开
-
单链表——C++模板实现
用模板技术实现链表可适用不同类型的数据类型单链表:每个结点只包含该结点存储的数据以及直接后继的地址信息头结点:头结点不存储数据但是存储下一个结点的地址,只是用来方便遍历链表这里的头结点,需要单独来处理,因为当泛指类型为类类型时,若由于研发人员定义的类有问题,然后存储在链表里,那么抛异常就会抛到链表类这里来了,所以头结点的value用占位数组char reserved[sizeof(T)...原创 2020-04-06 21:11:58 · 930 阅读 · 0 评论 -
冒泡排序——函数模板实现
要点:1、冒泡排序就是从水底(数组尾部),把小的重量轻的,往水面上浮(移到数组头部)2、从尾部开始,两两比较,若后一个比前一个小,则交换位置。#include <iostream>using namespace std;template <typename T>static void Swap(T& a, T& b){ T ...原创 2020-04-05 00:32:08 · 2106 阅读 · 0 评论 -
快速排序——函数模板实现
要点:1、大于基准pv的数放在一边,小于pv的放在另一边.2、Partition函数返回基准数的位置pivot对基准的左边快排Quick(array, begin, pivot-1);对基准的右边快排Quick(array, pivot+1, end);3、递归求解,直到不满足begin<end#include <iostream>using...原创 2020-04-04 21:35:38 · 398 阅读 · 0 评论 -
strstr函数实现——KMP算法
#include <iostream>#include <cstring>#include <cstdlib>using namespace std;//s:子串int* make_ptm(const char* p){ int len = strlen(p); int* ret = static_cast<int*&...原创 2020-03-15 10:47:16 · 247 阅读 · 0 评论