- 博客(9)
- 资源 (1)
- 收藏
- 关注
原创 刑侦推理暴力解法c++版
#include<iostream>#include<cmath>#include<vector>using namespace std;int an[10] = { 0 };bool isnb(int a, int b){ return (a - b == -1) || (a - b == 1);}void print(){ for...
2018-03-05 01:27:28
474
转载 【转】 OO七大原则
转自http://blog.youkuaiyun.com/ql15010832315/article/details/53127724OO七大原则为:单一职责原则、开闭原则、里氏替换原则、依赖倒置原则、接口隔离原则、合成/聚合复用原则、迪米特法则1、单一职责原则SRP(Simple Responsibility Principle):单一职责原则,就是一个设计元素只做一件事。什么是
2016-11-11 19:01:55
309
转载 【转】一个C语言宏展开问题
转自 http://www.cnblogs.com/9sheng/archive/2011/03/22/2684247.html一个令人比较迷惑的问题,学C语言好多年,今天终于搞明白,记之。1 #define cat(x,y) x ## y2 #define xcat(x,y) cat(x,y)3 cat(cat(1,2),3) //为什么不是 123?4 xcat(x
2016-11-03 10:51:47
732
转载 C++中运算符New的三种使用方式
转自:http://badboywang.iteye.com/blog/4463501. plain new 普通new[cpp] view plain copyvoid*operator new(std::size_t)throw(std::bad_alloc); void operator delete( void *) thro
2016-10-11 23:32:58
1028
原创 c++中定制输入输出操作
用模板重载友元操作符即可直接代码class test{ int out=0; int in; template friend T& operator >>(T& instream, test t); template friend T& operator <<(T& outstream, test t);};templateT& operator >>(T& instr
2016-09-02 21:50:32
325
原创 函数指针作为模板函数的非模板参数
template int search(T* pt, int size, T t, bool(*f)(T t1, T t2)){ for (int i = 0; i != size; ++i) { if (f(t, pt[i])) return i; } return size;}上面的search目的是在T类型的数组中按照f方法查找元素t
2016-08-30 13:22:18
621
2
原创 字符串匹配
今天看算法导论,看到了一个字符串匹配算法特别有意思,有限自动机字符串匹配算法说它有意思是因为算法维护了一个类似卡诺图的状态转换表,对于当前状态,接受不同字符转移到不同的状态,详情参考:https://zh.wikipedia.org/wiki/%E7%A1%AE%E5%AE%9A%E6%9C%89%E9%99%90%E7%8A%B6%E6%80%81%E8%87%AA%E5%8A%A8%E6%
2016-08-28 23:52:08
457
原创 c++在线笔记
函数模板形如:template //没有分号T sum(T a , T b){……}T为数据类型即定义时不给出返回值和参数类型,引用时自动填充此举会覆盖全局名使用类模板定义对象时使用如下形式:类模板名实际类型名> 对象名;类模板名实际类型名> 对象名(实参列表);如果在类模板之外定义成员函数,应该写成类模板形式:template class 虚拟参
2016-07-30 16:41:34
279
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人