原创 __FILE__,__LINE__,FUNCTION__實現代碼跟蹤調試(linux下c語言編程 )

__FILE__,__LINE__,FUNCTION__實現代碼跟蹤調試(linux下c語言編程 )先看下簡單的初始代碼:注意其編譯運行後的結果。 root@xuanfei-desktop:~/cpropram/2# cat glob

原创 使用存儲映射I/O函數mmap進行文件拷貝

       使用存儲映射I/O函數mmap進行文件拷貝比調用read和write函數更快,因爲mmap映射兩個文件到內存之後可以使用memcpy直

原创 epoll 水平觸發和邊緣觸發

       假設內核緩衝區中有2k數據,你只讀了1k到應用程序緩衝區。當使用水平觸發選項註冊描述符時epoll會通知應用程序還有數據沒有讀取。如果

原创 輸入兩個整數 n 和 m,從數列 1,2,3.......n 中隨意取幾個數, 使其和等於 m ,要求將其中所有的可能組合列出來.

#include <iostream> #include <vector> using namespace std; // 顯示組合 void showCombination(const vector<int>& s) { for(in

原创 循環遞增數組中查找是否存在某個數

#include <cassert> #include <iostream> using namespace std; // 在循環遞增數組中查看是否存在某個數 // 返回-1表示數組中沒有該元素 int search(int arr[]

原创 求出sum=1+11+111+1111+ .... + 111...111(1024個1),sum有多少個1

先列一個加法豎式:                   1                   1 1                 1 1 1               1 1 1 1                 .    

原创 數組中數字的所有組合情況

#include <queue> #include <vector> #include <iostream> using namespace std; // 列出數字的所有組合情況 // 使用樹的層次遍歷 void Combination

原创 宏定義和函數定義衝突會怎樣?

#include <iostream> #define add(a, b) ((a) + (b)) using namespace std; int add(int a, int b) { return a + b; } int ma

原创 輸入一個字符串,如何求最大重複出現的字符串

輸入一個字符串,如何求最大重複出現的字符串呢?比如輸入 ttabcftrgabcd,輸出結果爲 abc,canffcancd,輸出結果爲 can。 #include <iostream> #include

原创 二叉樹建立,遞歸,非遞歸,前序,中序,後序遍歷

#include <cstring> #include <iostream> #include <stack> #include <iomanip> using namespace std; struct TreeNode { int

原创 解一道遞歸調用題

int ack(int m, int n) { if(m == 0) return n + 1; else if(n == 0) return ack(m - 1, 1); else return ack(m - 1,