摘要:
考虑下面这种经常出现的使用方式:class webBroswer{public: ... void clearCache(); void clearHistory(); void removeCookies(); ...};那么很自然的就会想到增加这么一种清理方式:cl... 阅读全文
摘要:
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 ... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
protected成员变量的封装性并非高于public变量。如果有个public的成员变量,一旦其需要改变,那么所有使用它的代码都需要改变。如果有个protected的成员变量,一点其需要改变,那么所有的继承自他的derived class都需要重新改变。这与上面孰轻孰重其实不重要所以说,往往只有两... 阅读全文
摘要:
//先看看下面这个例子class Rational{public: Rational(int num, int denu) :numirator(num), denumirator(denu); const Rational operator*(const Rational & l... 阅读全文
摘要:
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... 阅读全文