以下是這次被問到的題目,做個記錄,順便分享給大家。
Q1: 一個單調遞增(strictly increase)的array <1,3,5,6,7,8,11,14>,被人切成兩半再接起來變成<7,8,11,14,1,3,5,6>,請問要怎麼找到最小值?
今天遇到一個有趣的面試問題跟大家分享:
假如去買運彩,冠軍四強的賠率分別是:2、3、4、5,請問莊家預期報酬的比率是多少?
class A { public: A() : _n(1) { } protected: int _n; }; class B : public A { public: B() : _m(_n) { } private: int _m; };
兒子不能用Private,朋友可以
class Ball;int compare(Ball&, Ball&);class Ball { public: .... // 宣告朋友類別 friend class SomeClass; // 宣告朋友函式 friend int compare(Ball&, Ball&);private: ....};
friend int compare(Ball&, Ball&);
class Line{ Line( int len ); // 建構式 Line( const Line &obj); // 拷貝建構式 ~Line(); // 解構式}
用來當作別名