文章
C++ 中的未定义行为
现在我们需要一个程序从控制台读入一个INT型整数(输入确保是INT),然后输出其绝对值,你可能闭着眼睛就会写出下面的代码:<pre<codeinclude<iostream>intmain(){intn;std::cin>>
并查集
<pre<codeclassUnionFindSets{intfather,rank;public:UnionFindSets(intN){fathernewintN,ranknewintN;fo
智能指针shared_ptr(effective modern c++笔记)
shared_ptr很多编程语言都有GC的机制,可以自动管理内存资源,然后GC机制带来的是资源释放的不确定性,c原始的手工管理内存资源的方式虽然具有释放的确定性,但是人工管理非常容易出错;如何既能自动释放内存又能保证确定性呢,modernc给出的方案是shared_ptr。
小顶堆
<pre<code//MinStack小顶堆开始template<typenameT>classMinHeap{intmaxHeapSize;Theap;intcurrentSize;voidshiftDow
图论
<pre<codeintchoose(intdistance,intn,boolfound){intminINT_MAX,minpos1;for(inti0;i<n;i)if(distancei&
gdb (lldb)
gdb(lldb)编译选项<pre<code$gg<程序名>.cppo<程序名></code</pre开始调试<pre<code$gdb<程序名>(gdb)</co
二分法查找
<pre<codeinclude<iostream>//Bsearch二分法查找开始template<typenameData>intBsearch(Dataa,Datav,ints,inte,int(compare)
二叉树
<pre<code//Tree二叉树开始template<typenameData>classTree{Datadata;Treell,rr;public:Tree(Dataa){data
全排列和组合
<pre<code//permute全排列开始template<typenameData>void_permute(Dataa,intn,intk,void(f)(Data,int)){if(k1n)f(a,n
C++ 并发编程(六):信号量(Semaphore)
下面这段介绍,修改自wxWidgets官方文档(详见:wxSemaphoreClassReference(https://link.segmentfault.com/?encl4ePi%2BCrGaCZawSoWUUlrw%3D%3D.VXDzzuz5QdkQm3WV%2FmjBU4C
已加载文章中没有匹配内容,试试其他关键词或清空搜索。