2014年10月8日

C++之vector

摘要: 1、简介Vector属于顺序容器,代表可改变大小的数组。像数组一样,vector使用连续存储,意味着它们的元素可以使用偏移来访问。不同于数组,它们的规模可以动态改变。Vectors are sequence containers representing arrays that can change... 阅读全文

posted @ 2014-10-08 15:53 erli11 阅读(168) 评论(0) 推荐(0)

2014年9月26日

[leetcode] Word Break

摘要: 1 problemGiven a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.F... 阅读全文

posted @ 2014-09-26 12:35 erli11 阅读(168) 评论(0) 推荐(0)

2014年9月25日

[leetcode] Best Time to Buy and Sell Stock

摘要: Problem:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transac... 阅读全文

posted @ 2014-09-25 18:08 erli11 阅读(218) 评论(0) 推荐(0)

2014年9月11日

#leetcode#Linked List Cycle

摘要: 1、题目Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?2、思路设置两个指针,一个每次走一步,另一个每次走两步。走两步的一定会追上走... 阅读全文

posted @ 2014-09-11 17:47 erli11 阅读(133) 评论(0) 推荐(0)

2014年9月9日

#leetcode# String to Integer

摘要: 题目来自:https://oj.leetcode.com/problems/string-to-integer-atoi/1、题目简介Implementatoito convert a string to an integer.Hint:Carefully consider all possible... 阅读全文

posted @ 2014-09-09 21:04 erli11 阅读(157) 评论(0) 推荐(0)

2014年8月19日

c/C++字符串操作

摘要: C字符串有3种编码模式,并对应3种字符类型。 (1)单字节字符集(single-byte character set (SBCS)). -在这种编码模式下,所有的字符都只用一个字节(Byte)标示。 -ASCII是SBCS,用一个字节标示为'\0'的来标识SBCS字符串的结束 -单字节字符包含拉丁文... 阅读全文

posted @ 2014-08-19 15:01 erli11 阅读(348) 评论(0) 推荐(0)

2014年7月28日

C/C++之时间差计算

摘要: 1、clock函数C/C++中的计时函数是clock(),而与其相关的数据类型是clock_t。在MSDN中,查得对clock函数定义如下: clock_t clock( void ); 这个函数返回从“开启这个程序进程”到“程序中调用clock()函数”时之间的CPU时钟计时单元(clock ti... 阅读全文

posted @ 2014-07-28 14:28 erli11 阅读(11252) 评论(0) 推荐(0)

2014年7月17日

C++之类析构函数为什么是虚函数

摘要: 请说明下列代码的输出,并解释原因。#includeclass A{public: virtual ~A();};A::~A(){ printf("delete A\n");}class B : public A{public: ~B();};B::~B(){ printf("... 阅读全文

posted @ 2014-07-17 11:54 erli11 阅读(235) 评论(0) 推荐(0)

2014年7月9日

C++之类构造函数初始化列表

摘要: 构造函数初始化列表以一个冒号开始,接着是以逗号分隔的数据成员列表,每个数据成员后面跟一个放在括号中的初始化式。例如:class Example {public: int a; float b; //构造函数初始化列表 CExample(): a(0),b(8.8) {}... 阅读全文

posted @ 2014-07-09 14:33 erli11 阅读(1214) 评论(0) 推荐(0)

2014年7月7日

C/C++之智能指针shared_ptr

摘要: 1、定义shared_ptr的作用有如同指针,但会记录有多少个shared_ptrs共同指向一个对象。这便是所谓的引用计数(reference counting)。一旦最后一个这样的指针被销毁,也就是一旦某个对象的引用计数变为0,这个对象会被自动删除。这在非环形数据结构中防止资源泄露很有帮助。aut... 阅读全文

posted @ 2014-07-07 17:39 erli11 阅读(1163) 评论(0) 推荐(0)

导航