摘要: 考虑下面这种经常出现的使用方式:class webBroswer{public: ... void clearCache(); void clearHistory(); void removeCookies(); ...};那么很自然的就会想到增加这么一种清理方式:cl... 阅读全文
posted @ 2015-10-07 22:40 eversliver 阅读(282) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest ... 阅读全文
posted @ 2015-10-07 22:13 eversliver 阅读(322) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integernum, repeatedly add all its digits until the result has only one digit. For example: Givennum = 38, the process is lik... 阅读全文
posted @ 2015-10-07 17:28 eversliver 阅读(423) 评论(0) 推荐(0) 编辑
摘要: Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
posted @ 2015-10-07 17:02 eversliver 阅读(493) 评论(0) 推荐(0) 编辑
摘要: protected成员变量的封装性并非高于public变量。如果有个public的成员变量,一旦其需要改变,那么所有使用它的代码都需要改变。如果有个protected的成员变量,一点其需要改变,那么所有的继承自他的derived class都需要重新改变。这与上面孰轻孰重其实不重要所以说,往往只有两... 阅读全文
posted @ 2015-10-07 14:52 eversliver 阅读(212) 评论(0) 推荐(0) 编辑
摘要: //先看看下面这个例子class Rational{public: Rational(int num, int denu) :numirator(num), denumirator(denu); const Rational operator*(const Rational & l... 阅读全文
posted @ 2015-10-07 14:36 eversliver 阅读(297) 评论(0) 推荐(0) 编辑
摘要: Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For examp... 阅读全文
posted @ 2015-10-07 10:56 eversliver 阅读(222) 评论(0) 推荐(0) 编辑