原创 Effective C++ 專欄

Sccot Meyer 的 Effective C++

原创 HackerRank: Extraordinary long factorial

思路: 用vector保存結果的每一位 代碼: void extraLongFactorials(int n) { if (n == 1) { cout << 1 << endl; retu

原创 Hacker Rank: Magic Square Diff

From 1 - 9 , sum is 45. each Line and each Row 15 The 8 valid combinations of 3 numbers that add to 15 are: 9 5 1 7

原创 堆排序 比較簡單的做法

最大堆 進行升序排列 步驟 函數maxHeaptify(int a[], int s, int e) 在s 和 e 間構造大頂堆 c = s, l = 2*c+1, tmp = a[c]; 如果l < e 而且 a[l] <

原创 模板編程,constexpr, 遞歸/非遞歸 Benchmark Fibonacci計算

五種實現Fibonacci數列的方式 實現方式 1. 模板 使用effective C++中提到的enum hack, 這也是meta programming的基礎技術。 template <unsigned long long

原创 HackerRank: Non-Divisible Subset

考慮事項: remainder[k/2] = 1 remainder[0] 裏面只能抽出一個 即 remainder[0] = std::min(remainder[0], 1) and remainder[k/2] = st

原创 共享內存IPC在交易系統中應用

共享內存IPC在交易系統中應用

原创 使用模板計算

直接上代碼如下 知識點 enum hack next M and next N 模板特化 模板默認參數 printt不相關, // 測試可變模板 void printt() { } template<typename T,

原创 premake sample

premake 示例 solution "MyApplication" configurations { "Debug", "Release" } -- A project defines one build tar

原创 FlatBuffer 上手體驗

FlatBuffer上手體驗 安裝flatc 下載github源代碼 https://google.github.io/flatbuffers/ 本地編譯安裝 cmake -G "Unix Makefiles" -DCMAKE