摘要: 集合类简介集合让程序员能在容器中快速的查找键(键:存储在一维容器中的值)set和multiset之间的区别就是set中的值唯一,multiset中的值可以不唯一。为实现快速搜索,集合的内部结构像二叉树,插入数据时对其进行排序。#include 实例化以set为例,multiset同样1 set se... 阅读全文
posted @ 2014-04-18 09:50 猫了个妖喵 阅读(218) 评论(0) 推荐(0) 编辑
摘要: What’s iterator?template classGeneric PointerGetting an iterator1 auto itr=container.cbegin();2 auto itr=container.cend();Iterator methods1 ++itr2 *it... 阅读全文
posted @ 2014-04-17 10:24 猫了个妖喵 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Question:Given intergers A1,A2,…,An,find the maximum Subsequence Sum ProblemSolution:有很多方法可以解决这个问题。下面我只给出我认为最好的算法。 1 //linear-time maximum contiguous ... 阅读全文
posted @ 2014-04-16 09:10 猫了个妖喵 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Question:computing the greatest common divisorSolution: 1 template 2 T gcd(T m,T n) 3 { 4 if(m<n) 5 { 6 T temp = a; 7 a=b;... 阅读全文
posted @ 2014-04-16 09:05 猫了个妖喵 阅读(85) 评论(0) 推荐(0) 编辑
摘要: Question:Given an interger X and intergers A0,A1,……,A(n-1), which are presorted and already in memory,find i such that Ai=X, or return i=-1 if X is no... 阅读全文
posted @ 2014-04-15 22:00 猫了个妖喵 阅读(143) 评论(0) 推荐(0) 编辑
摘要: list简介#inlude 实质为双向链表是类模板实例化example: 1 //instantiate an empty list 2 list listA; 3 4 //instantiate a list with 7 intergers,each initialized to 0 5 li... 阅读全文
posted @ 2014-04-15 13:23 猫了个妖喵 阅读(125) 评论(0) 推荐(0) 编辑