?注意下面的注释,对于地址重叠的情况,该函数的行为是未定义的。事实上所说的陷阱也在于此,自己动手实现memcpy()时就需要考虑地址重叠的情况。另外,标准库也提供了地址重叠时的内存拷贝函数:memmove(),那么为什么还要考虑重写memcpy()函数呢?因为memmove()函数的实现效率问题,该... ...
分类:
其他好文 时间:
2017-05-01 11:05:22
阅读次数:
192
int bubbleSort1(int* array,int len ) { int i ,j,temp; i = j = temp = 0; for( i = 0; i i;j-- ) { if( array[j-1] > array[j] ) { temp = ... ...
分类:
编程语言 时间:
2017-04-21 19:10:35
阅读次数:
244
这篇文章我们继续学习main方法,我们先来看看 ngx_debug_init() 这个方法。从方法名我们也知道,debug初始化。我们先看看方法位置在哪。我们来断点在这个方法上面。 Function “ngx_debug_init” not defined。 我们去源码里面查找,grep “ngx_ ...
分类:
其他好文 时间:
2017-04-20 22:49:16
阅读次数:
199
#include #include using namespace std; void* my_memcpy(void* dest,const void* src,unsigned int count) { if (dest == NULL || src == NULL) { return NULL... ...
分类:
其他好文 时间:
2017-04-11 09:19:49
阅读次数:
177
#include #include #include #include #include #include #include using namespace std; /* 2 6 4 1 3 7 0 5 8 8 1 5 7 3 6 4 0 2 1 2 3 4 5 0 7 8 6 1 2 3 4 5... ...
分类:
其他好文 时间:
2017-04-04 16:13:59
阅读次数:
245
#include #include #include #include using namespace std; int main() { typedef int Status[3]; int a[3][3]; for (int i = 0; i c: 1 , 2.b == c: 0, 3.b < ... ...
分类:
其他好文 时间:
2017-04-04 15:13:38
阅读次数:
124
腊鸡题目,实在卡不过去。 (改了一下午) 就是裸的斯坦纳树的题目,一方面合并子集,另一方面SPFA迭代求解。 优化了许多地方,甚至基数排序都写了。 还是T到死,不打算改了,就这样吧 ...
Description 给定一张有向图,每条边都有一个容量C和一个扩容费用W。这里扩容费用是指将容量扩大1所需的费用。求: 1、 在不扩容的情况下,1到N的最大流; 2、 将1到N的最大流增加K所需的最小扩容费用。 Input 输入文件的第一行包含三个整数N,M,K,表示有向图的点数、边数以及所需要 ...
分类:
Web程序 时间:
2017-03-26 01:20:37
阅读次数:
274
单例模式就是一个C++语法精华浓缩的一个体现,有句老话:麻雀虽小五脏俱全!来形容单例非常贴切! 下面的代码分析了如果自己malloc并且memcpy一个单例指针会带来很大危害并如何防止这种情况发生。 总结: 1、以上单例是比较常见的实现 2、memcpy会破坏这个单例的唯一性 3、memcpy出来的 ...
分类:
编程语言 时间:
2017-03-24 13:28:47
阅读次数:
131