随笔分类 -  C++

摘要:参考>shared_ptr类摘要(只列出了常用的部分)和相关说明 1 template class shared_ptr { 2 public: 3 typedef T element_type; 4 shared_ptr(); 5 template explicit sh... 阅读全文
posted @ 2015-11-21 10:32 roger9567 阅读(251) 评论(0) 推荐(0)
摘要:-当直接传递变量给一个函数的时候 , 实际上传递的是这个变量的copy, 修改这个copy不会影响到原来的变量. -当传递一个指向这个变量的指针到函数的时候, 实际上传递的是这个指针的copy, 修改这个copy不会影响到原来的指针所指的位置, 但是修改这个copy内的值就影响了指针指向的变量... 阅读全文
posted @ 2015-10-26 00:31 roger9567 阅读(339) 评论(0) 推荐(0)
摘要:#include | #include | #include 1. 判断式 - for 搜索算法: 传递一个函数或函数对象, 指定一个一元判断式可以作为搜索准则 - for 排序算法: 传递一个函数或函数对象, 指定一个二元判断式可以作为排序准则 - for 过滤: 传递一个一元判断... 阅读全文
posted @ 2015-10-18 20:13 roger9567 阅读(207) 评论(0) 推荐(0)
摘要:string | array | hash1. string - 可以视为以字符为元素的一种容器, 可以在字符上进行遍历, 提供begin()/end() - 为了支持迭代器和迭代器适配器 , string提供了一些操作函数, 如 push_back().2. array - 可以将数组也当作... 阅读全文
posted @ 2015-10-18 20:13 roger9567 阅读(159) 评论(0) 推荐(0)
摘要:1. 所在头文件. 命名空间std, 声明如下: 1 namespace std{ 2 template , 4 class Allocator = allocator > > 5 class map; 6 template , 8 ... 阅读全文
posted @ 2015-10-18 19:06 roger9567 阅读(182) 评论(0) 推荐(0)
摘要:1. 所在头文件: , 命名空间: std ; 声明如下: 1 namespace std{ 2 template , 4 class Allocator = allocator > 5 class set; 6 template , 8 ... 阅读全文
posted @ 2015-10-18 17:13 roger9567 阅读(177) 评论(0) 推荐(0)
摘要:0. 内容为个人学习笔记, 仅供参考, 如有错漏, 欢迎指正!1. STL中的所有组件都是由模板构成的, 所以其元素可以是任意型别的. 组件有: - 容器: 管理某类对象的集合. 不同的容器有各自的优缺点. - 迭代器: 用来在一个对象集群(Collection of Objects) 的元素上... 阅读全文
posted @ 2015-10-18 02:03 roger9567 阅读(215) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=17001. 当1个人时: 直接过河 t[0].2. 当2个人时: 时间为较慢的那个 t[1].3. 当3个人时: 时间为 t[0]+t[1]+t[2].4. 当4个以上的人时, 将t[0] 和 t[1]当作搬运工. 两种方案: - 最... 阅读全文
posted @ 2015-10-17 16:32 roger9567 阅读(149) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=1256题意: 根据自定义的字典序:'A'#include #include using namespace std;int mp[13]; // 字符串中的各个字符按相对大小映射到mp中.int main(){ int T,n; ... 阅读全文
posted @ 2015-10-17 12:52 roger9567 阅读(152) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=1118题意: 给定n个点, 求在同一直线上的点最多的直线上点的数目.解法: 简单题目, 规模比较小, 暴力搜索.#include using namespace std;#define MAXN 700struct Point{ ... 阅读全文
posted @ 2015-10-17 12:04 roger9567 阅读(111) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=1146题意: 给定一个字符串(长度不超过50), 求这个字符串的下一个字典序的字符串, 如果已经是最大字典序, 那么输出 "No successor".分析: 中有一个现成的next_permutation(begin, end), 对... 阅读全文
posted @ 2015-10-17 11:46 roger9567 阅读(154) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=1045一道数学物理题, 推理公式:http://www.cnblogs.com/rainydays/archive/2013/01/08/2851741.html代码:#include #include #include using n... 阅读全文
posted @ 2015-10-17 09:56 roger9567 阅读(110) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=1083题意: 走廊两边分别有200个房间,一边连续编号为1-399的奇数,另一边是2-400的偶数, 如果从房间 i 移动桌子到房间 j , 由于走廊宽度只能允许一次通过一张桌子, 那么给定一些移动方案, 求最小的移动时间(移动一次需要... 阅读全文
posted @ 2015-10-17 09:36 roger9567 阅读(187) 评论(0) 推荐(0)
摘要:今晚学了一下C++标准程序库, 来简单回顾和总结一下。 1.pair 结构体// defined in , in the std namespacenamespace std{ template struct pair{ // type names for the... 阅读全文
posted @ 2015-09-04 22:34 roger9567 阅读(217) 评论(0) 推荐(0)