摘要: #include using namespace std; template class SmartPtr { public: SmartPtr(T *p); ~SmartPtr(); SmartPtr(const SmartPtr &orig); // 浅拷贝 SmartPtr& operator=(const SmartPtr... 阅读全文
posted @ 2017-06-15 16:46 mximo 阅读(171) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; static const int BUFFERSIZE = 10; static const int PRODUCT_NUM = 50; HANDLE mutex; HANDLE fullSemaphore; HANDLE emptySemaphore; int real_product_num... 阅读全文
posted @ 2017-06-15 16:30 mximo 阅读(265) 评论(0) 推荐(0) 编辑
摘要: STL提供了很多泛型容器,如vector,list和map。程序员在使用这些容器时只需关心何时往容器内塞对象,而不用关心如何管理内存,需要用多少内存,这些STL容器极大地方便了C++程序的编写。例如可以通过以下语句创建一个vector,它实际上是一个按需增长的动态数组,其每个元素的类型为int整型: 阅读全文
posted @ 2017-06-15 10:09 mximo 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 编译,编译程序读取源程序(字符流),对之进行词法和语法的分析,将高级语言指令转换为功能等效的汇编代码,再由汇编程序转换为机器语言,并且按照操作系统对可执行文件格式的要求链接生成可执行程序。 源代码-->预处理-->编译-->优化-->汇编-->链接-->可执行文件 Source--(编译)--> A 阅读全文
posted @ 2017-06-15 09:27 mximo 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 一、宏定义和内联函数的区别 1. 宏定义不是函数,但是使用起来像函数。预处理器用复制宏代码的方式代替函数的调用,省去了函数压栈退栈过程,提高了效率。 内联函数本质上是一个函数,内联函数一般用于函数体的代码比较简单的函数,不能包含复杂的控制语句,while、switch,并且内联函数本身不能直接调用自 阅读全文
posted @ 2017-06-15 09:17 mximo 阅读(1005) 评论(0) 推荐(0) 编辑
摘要: 在数组中找到第k大的元素 注意事项 你可以交换数组中的元素的位置 您在真实的面试中是否遇到过这个题? Yes 在数组中找到第k大的元素 注意事项 你可以交换数组中的元素的位置 在数组中找到第k大的元素 注意事项 你可以交换数组中的元素的位置 你可以交换数组中的元素的位置 你可以交换数组中的元素的位置 阅读全文
posted @ 2017-06-14 21:20 mximo 阅读(234) 评论(0) 推荐(0) 编辑
摘要: Remove all elements from a linked list of integers that have valueval. Have you met this question in a real interview? Yes Remove all elements from a 阅读全文
posted @ 2017-06-13 22:14 mximo 阅读(610) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. Notice Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list. Have you met this question 阅读全文
posted @ 2017-06-13 22:11 mximo 阅读(144) 评论(0) 推荐(0) 编辑
摘要: floyd Floyd算法是一个经典的动态规划算法。用通俗的语言来描述的话,首先我们的目标是寻找从点i到点j的最短路径。从动态规划的角度看问题,我们需要为这个目标重新做一个诠释(这个诠释正是动态规划最富创造力的精华所在) 从任意节点i到任意节点j的最短路径不外乎2种可能,1是直接从i到j,2是从i经 阅读全文
posted @ 2017-06-13 15:40 mximo 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree. Notice Yo 阅读全文
posted @ 2017-06-12 17:16 mximo 阅读(297) 评论(0) 推荐(0) 编辑