摘要: // range heap example#include // std::cout#include // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap#include // std::ve... 阅读全文
posted @ 2016-01-06 09:11 飞飞喵 阅读(218) 评论(1) 推荐(0)
摘要: 定义queue对象的示例代码如下:queue q1;queue q2;queue的基本操作有:入队,如例:q.push(x); 将x接到队列的末端。出队,如例:q.pop(); 弹出队列的第一个元素,注意,并不会返回被弹出元素的值。访问队首元素,如例:q.front(),即最早被压入队列的元素。访问... 阅读全文
posted @ 2016-01-06 05:09 飞飞喵 阅读(144) 评论(0) 推荐(0)
摘要: 多数派问题()'''在O(n)时间复杂度,O(1)空间复杂度内,判断是否有候选人的得票数过半该算法在运行过程中,需要两个临时变量c和t,c记录当前可能得票数过半的候选人编号,t记录该候选人的净超出次数。对于c而言,除了可以等于1~m中的任何值之外,还有另一种状态,我们把其叫做未知状态,用于表示当前任... 阅读全文
posted @ 2016-01-03 04:44 飞飞喵 阅读(224) 评论(1) 推荐(0)
摘要: string substr (size_t pos = 0, size_t len = npos) const;// string::substr#include #include int main (){ std::string str="We think in generalities, bu... 阅读全文
posted @ 2015-12-31 12:00 飞飞喵 阅读(452) 评论(0) 推荐(0)
摘要: int main(int argc, const char * argv[]) { // insert code here... string a = ""; cout<<a.size()<<endl; cout<<a.size()-1<<endl; cout<<a.... 阅读全文
posted @ 2015-12-31 11:56 飞飞喵 阅读(626) 评论(3) 推荐(0)
摘要: 初始化 关于capacity 和 reserve: 阅读全文
posted @ 2015-12-30 06:49 飞飞喵 阅读(169) 评论(0) 推荐(0)
摘要: 遍历mapit->first it->second#include#include#includeint main(){map words;map::iterator it=words.begin();for(;it!=words.end();++it) coutfirst ... 阅读全文
posted @ 2015-12-30 06:48 飞飞喵 阅读(112) 评论(0) 推荐(0)
摘要: http://www.cplusplus.com/reference/climits/ INT_MAX, INT_MIN 阅读全文
posted @ 2015-12-29 06:48 飞飞喵 阅读(460) 评论(2) 推荐(0)
摘要: set 是binary search tree. find count lower_bound upper_bound equal_range set的元素最好不要修改: 阅读全文
posted @ 2015-12-29 05:01 飞飞喵 阅读(146) 评论(0) 推荐(0)
摘要: Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + ... 阅读全文
posted @ 2015-11-19 13:39 飞飞喵 阅读(193) 评论(1) 推荐(0)