自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

yue_wei_的专栏

人生匆匆数十载,幕起幕落而已

  • 博客(14)
  • 资源 (4)
  • 收藏
  • 关注

原创 高效的插入排序

#include using namespace std; template//插入排序的辅助函数1 inline void InnerInsert(RandomAccessIterator first,RandomAccessIterator last,T *); template//插入排序的辅助函数2 inline void UnguardedInnerInsert(Ra

2012-11-22 20:50:35 450

原创 以相同概率输出0、1

//以相同概率输出0或1,其他1/N概率同理 int f() {     int i = rand()%10;     return (i } int g() {     int firstNumber = 0,secondNumber = 0;     while(firstNumber == secondNumber)     {         firstNumber

2012-11-08 22:35:32 527

原创 单链表置逆

//C++11,其他版本将nullptr改为NULL或0即可 template class List {     struct ListNode     {         T value;         ListNode *next;         ListNode(const T&_value,ListNode *_next = nullptr)

2012-11-06 15:36:20 655

原创 虚构造函数和虚析构函数

1.析构函数可以为虚函数,且基类的析构函数一般均为虚函数。     原因在于:通过基类指针delete *base;时,可以通过虚的析构函数来释放掉派生类独自占用的内存,避免资源泄露。 2.构造函数不可为虚函数。     原因在于:构造函数是在对象完全构造之前运行的,在构造函数运行的时候,对象的动态类型还不完整。                         构造一个对象的时候,必须知道

2012-11-05 20:20:46 841

原创 在字符串中找出第一个只出现一次的字符

/*在一个字符串中找到第一个只出现一次的字符。如输入abaccdeff,则输出b.没有则返回'#'*/ #include #include using namespace std; char FindFirstOneTime(const string &str) {     char result = '#';     map map; //考虑到字符串长度未必巨大,故使用map

2012-11-05 08:56:48 494

原创 C++中的new与delete

1:  new operator(就是我们平时使用的new),会将对象产生于heap。(不但分配内存,还会为该对象调用构造函数) 2:operator new。只为对象分配了内存,并没有调用构造函数。(STL中的默认空间配置器所使用的方法) 3:重载operator new。当调用new之后,会自动调用重载的operator new,按照自己的方式分配空间,并初始化对象。(ps:我们可

2012-11-04 22:45:38 381

原创 在大量URL中,查找出现次数前K多的URL

#include #include #include #include #include #include using namespace std; using namespace stdext; void FindTopKTimes(const string &fileName) { ifstream fin; fin.open(fileName.c_str

2012-11-04 15:52:16 690

原创 判断一个数组是否为二叉树的后序遍历

bool IsTree(vector::iterator &begin,vector::iterator &end) {     if(distance(begin,end) == 1 || begin == end)         return true;     vector::iterator iter = end;     --iter;     vector::iterat

2012-11-04 13:39:02 590

原创 Sleep排序

vector SleepSort(vector &,int); void SleepSort(vector &vec) {     vec = SleepSort(vec,0); } vector SleepSort(vector &vec,int) {     vector result;     vector threads;     for(size_t i = 0

2012-11-03 18:56:47 659

原创 最长递增子序列(LCS)

template vector::value_type> LCS(Iter begin,Iter end) { typedef typename iterator_traits::value_type Type; int dis = distance(begin,end); vector temp(dis,1); vector result; vector path(dis); a

2012-11-03 18:54:03 476

原创 dynamic_cast .vs. static_cast && static_cast .vs. reinterpret_cast

dynamic_cast .vs. static_cast class B { ... }; class D : public B { ... }; void f(B* pb) { D* pd1 = dynamic_cast(pb); D* pd2 = static_cast(pb); } If pb really points to an object of type D, th

2012-11-03 00:06:17 474

转载 求T的N次方

int Power(int T,int n) {     if(n == 0)         return 1;     while((n&1) == 0)     {         T *= T;         n>>=1;     }     int result = T;     n>>=1;     while(n != 0)     {     T *

2012-11-02 14:41:50 1532

原创 打印和为N的所有连续数列组合

void PrintComOfN(int n) {     int first = 1;     int last = 2;     int sum = first + last;     while(last     {     if(sum == n)     {         for(int i = first;i             cout

2012-11-02 14:24:34 1043

原创 TrieTree

#pragma once #include #include #include #include #include #include using namespace stdext; using namespace std; //#define _TRIETREE_SET class TrieTree { #ifdef _TRIETREE_SET struct

2012-11-01 18:21:53 556

Python编程金典

Python编程金典电子书,很清晰,很详细的说~

2012-10-28

信息检索导论

信息检索导论,很牛叉的一本书,大规模信息处理必备~

2012-10-28

unix编程艺术

unix编程艺术,经典之作,绝对值得一看。

2012-11-05

STL源码剖析

STL源码剖析,侯捷代表作之一,深入STL讲解

2012-11-04

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除