- 博客(20)
- 收藏
- 关注
原创 关于C++内存生长
今天看到网上帖子说计算机中内存的生长的方式是从高地址到低地址的,很久以前就了解过这个知识点,但还是不禁写了个代码试了一下。这一试发现了更多问题。测试代码如下:include #include struct TestType{ int _a; int _b; };int main(){ int a =
2015-08-22 21:06:55
576
原创 探秘TCP数据包中的PSH标志
今天在用wireshark分析TCP数据包的时候,发现一个特别的标志,PSH,和ACK一块使用的,不太了解,所以查了一下,发现大部分的解释都是不外乎表示这个包是带数据的,发送端告诉接收端,这个数据包以及以前接收到的数据包需要交给应用层立即进行处理。但是是什么样一种契机促使发送端添加了PSH标志呢?添加这个标志时发送端是怎样一种心情呢?(^_^) 查了一些材料,最终在《TCP/IP详解卷1:协议》这
2015-07-15 16:12:09
54235
1
原创 Cocos2dx中RotateTo对旋转方向的处理
今天在写个demo的时候意外发现了一个跟rotate相关的有趣的事情。 如果我们想要将一个物体旋转朝向另外一个物体的时候,一般都会采用如下的方法: // 通过tan值求arctan来得到旋转角度 auto diff = objRotateToward->getPosition() - objRotated->getPosition(); float angleRadians
2015-07-12 13:19:34
7628
原创 LeetCode 208 Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z.这个题比较简单,就是实现一个单词树,单词树的相关资料可以参考:http://www.cppblog.com/yuyang7/arc
2015-07-09 16:39:05
399
原创 LeetCode 208 Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z.这个题比较简单,就是实现一个单词树,单词树的相关资料可以参考:http://www.cppblog.com/yuyang7/arc
2015-07-09 16:36:53
353
原创 LeetCode 207 Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:
2015-07-09 11:54:18
387
原创 Leetcode 204 Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.求小于n的素数的数量。 最传统的做法就是做一个判定函数,从2开始到n判断,看有多少素数。判定素数的方法就是从2到根号n,看看是不是可以被n整除。但是看了提示后,发现还有别的便捷的方法来解,就是原始的Sieve of Eratosthene
2015-06-06 20:06:06
414
原创 Leetcode 201 Bitwise AND of Numbers Range
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5, 7], you should return 4.
2015-05-25 15:58:31
501
原创 C++模板类中的静态成员
今天看书看到关于C++中Template类的相关内容,涉及到静态成员。我们知道,模板类在使用的时候会根据指定的类型进行特化,这个过程发生在编译期。(需要注意的是模板类的静态成员在模板没有特化的时候是无法使用的。)但是模板类中的静态成员又是怎样的呢,是所有特化持有一份成员还是每一个特化均持有一份成员呢,经过测试,是后者,即每个特化类型均持有一个相应的静态成员。
2015-05-06 20:11:39
789
转载 欢迎使用优快云-markdown编辑器
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2015-05-06 16:52:34
336
转载 mac下gdb签名认证
转自:http://www.cnblogs.com/yishuiliunian/archive/2013/01/13/2858836.htmlIf you try to use your freshly built gdb, you will get an error message such as: Starting program: /x/y/foo
2015-03-13 14:54:23
454
原创 mac os下编译gcc4.9.2
最近在看C++原理相关的书,xcode所带的gcc的版本是4.2的,还是挺想在mac下使用高版本的gcc进行编译代码的,可以使用很多新特性,所以萌生了编译安装gcc的念头,网上找了一些材料,找到一篇英文的文章,参考着编译安装的,但是还是遇到了问题,英文原文链接:https://solarianprogrammer.com/2013/06/11/compiling-gcc-mac-os-x/
2015-03-13 00:46:01
1355
原创 Google 10月份在线笔试ProblemD(个人代码,未必最优,请不吝赐教)
ProblemTetris is a famous video game that almost everyone has played it. In this problem, you need to simulate a simplified version of it.In our version, the game is played in a W by H field wit
2014-10-25 15:10:15
782
原创 Google 10月份在线笔试ProblemC(个人代码,未必最优,请不吝赐教)
ProblemAlice is a smart student who is very good at math. She is attending a math class. In this class, the teacher is teaching the students how to use a calculator. The teacher will tell an integ
2014-10-25 14:57:40
623
原创 Google 10月份在线笔试ProblemB(个人代码,未必最优,请不吝赐教)
ProblemTom is taking metros in the city to go from station to station.The metro system in the city works like this:There are N metro lines in the city: line 1, line 2, ..., line N.For each
2014-10-25 14:47:25
583
原创 Google 10月份在线笔试ProblemA(个人代码,未必最优,请不吝赐教)
ProblemMinesweeper is a computer game that became popular in the 1980s, and is still included in some versions of the Microsoft Windows operating system. This problem has a similar idea, but it do
2014-10-25 14:30:20
535
原创 cocos2dx 3.0 找不到资源导致黑屏(用cocos new 创建的default工程一定要记得修改工作目录的配置)
昨天在调新工程的时候发现个问题,程序无法找到Resource目录下的资源,ranh
2014-05-12 23:55:04
2254
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人