
c++
文章平均质量分 63
杰拉德er
Practices make perfect.
展开
-
【面试题】判断链表中是否有环
1. 快慢指针/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: boo原创 2016-04-18 22:51:56 · 340 阅读 · 0 评论 -
[c++]set整理
1. set中元素必须有比较的方法 set中元素必须有比较顺序的方法,如下,如果自定义一个struct类型Node,定义set不会出错,向set中插入元素时编译出错:#include #include using namespace std;struct Node{ int i; int j; Node(int ii,int jj):i(ii),j(jj){} void p原创 2016-04-21 23:08:46 · 337 阅读 · 0 评论 -
[c++]traits
以后再添加自己的理解参考资料:简洁版 http://www.cnblogs.com/pugang/archive/2012/10/17/2727378.html 大神的代码 值得好好推敲 template第一次见追根溯源版http://www.cnblogs.com/youthlion/archive/2011/12/01/2255618.html转载 2016-04-20 16:18:29 · 253 阅读 · 0 评论 -
虚函数表
面试时被问到vpt怎么实现的,蒙了!!例子没有太太懂 Fun pfun1=(Fun)(*(long*)*(long*)&d1);得到虚表中第一个虚函数的地址参考:http://www.cppblog.com/ 好地方http://eriol.iteye.com/blog/1167737http://www.cnblogs.com/lihaosky/articles/160转载 2016-04-19 15:11:25 · 253 阅读 · 0 评论 -
[c++]非局部静态对象初始化顺序
参考effective c++腾讯面试题 全局变量初始化顺序1. static对象包括global对象、定义域namespace作用域内的对象、class内或者函数内或文件作用域内被声明为static的对象局部static对象,函数内声明的static对象,其他的都是全局static对象2. 编译单元 产生单一目标文件的源码,基本上是单一源码文件加上包含的头文件原创 2016-04-19 14:22:03 · 721 阅读 · 0 评论 -
[c++]const使用
参考effective c++1. 与指针配合char * str="Hello";const char * p = str;//指向常量的指针p[0]='h'; //wrongp="Hi"; //Okchar const * pp=str;//同上 只关心const相对于 * 位置char * const cp=str;//指针常量 不允许指向其他的地址cp[0]=原创 2016-04-19 10:54:40 · 236 阅读 · 0 评论 -
[c++] LeetCode Two Sum问题
谢谢师兄的推荐,LeetCode点击打开链接很适合来刷题,初步着手做编程练习题,下面是算法题第一题two sum问题的描述:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices翻译 2015-10-14 08:20:07 · 346 阅读 · 0 评论 -
[c++] LeetCode Add Two Numbers问题
问题描述:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i翻译 2015-10-14 15:24:20 · 448 阅读 · 0 评论 -
[c++] The BookStore Program
/* 程序来源于书本对应的程序代码 * This file contains code from "C++ Primer, Fifth Edition", by Stanley B. * Lippman, Josee Lajoie, and Barbara E. Moo, and is covered under the * copyright and warranty notices giv转载 2015-10-14 19:00:58 · 421 阅读 · 0 评论 -
[c++]类型转换
例子源于c++ primerbool b=10; // b is truebool b=-10;// b is truebool b=0.0;// b is falseint i=10.2;// i is 10 truncatedint j=-10.2;//j is -10undigned char c=-1; //assuming 8-bits char, c has value 2翻译 2015-10-14 19:50:24 · 610 阅读 · 0 评论 -
[c++]使用前后缀表示常量的类型
字符或字符串常量使用前缀PrifixmeaningTypeuunicode 16 characterchar16_tU................32...32Lwide characterwchar_tu8utf-8(string literals only)char翻译 2015-10-14 21:27:54 · 1437 阅读 · 1 评论 -
[c++] LeetCode longest substring without repeating characters问题
问题描述:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length i原创 2015-10-15 22:29:50 · 317 阅读 · 0 评论 -
[c++]LeetCode Median of Two Sorted Arrays问题
问题描述:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).总结大牛的算法如下:假设nums翻译 2015-10-18 08:54:35 · 319 阅读 · 0 评论 -
[c++]c++11 新标准
1. constexpr要求编译器去确认变量是常量表达式constexpr int sz=size(); //编译时除非size()是constexpr function,否则不通过当用constexpr修饰指针,说明是指针常量,不是指向常量的指针const int *p=nullptr; //指向常量的指针constexpr int *q=nullptr;//指针翻译 2015-10-16 16:25:31 · 290 阅读 · 0 评论 -
[c++]百度笔试题
进程调度算法中有一种最小执行时间优先SJF(shortest job first)的调度算法,当一个进程结束后,会选择进程执行时间最短的进行执行,如果执行时间出现相同的情况,考察进入时间,还出现相同,先列出的先执行。比如说进程到来的时间和需要的执行时间如下:进程进入时间执行需要时间实际执行时间等待时间a0700原创 2016-04-22 09:44:03 · 448 阅读 · 0 评论