Time of Update: 2018-12-04
我覺得這些函數 fill() fill_n() strcpy() strcpy() 大家都很熟悉,於是從百科貼幾個不常用的c函數,全當做自己學習。 1. memcpy() 原型:extern void *memcpy(void *dest, void *src, unsigned int count); 用法:#include
Time of Update: 2018-12-04
#include <windows.h>#include <tchar.h>#include <locale.h>#include <stdio.h>#include <atlstr.h> /** * @param cbCharSize: lpCharStr的位元組個數,可以設為-1,如果以null結束。 * @param cchWCharCnt: lpWCharStr的字元個數 * * @return:
Time of Update: 2018-12-04
Bridging signalsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 5919 Accepted: 3233Description'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up
Time of Update: 2018-12-04
對於很多人來說網路是必不可少的,那些網路電訊廠商為了獲得最大利益,會用各種辦法限制我們共用上網。無論在學生宿舍還是家裡,如果把自己能上網的一台電腦變成無線路由器供大家各種裝置共用上網,那麼就相當方便且省錢了!Maryfi 是一款免費的無線網路共用軟體,如果你恰好有一台帶無線網卡的 Windows7 電腦,那麼現在你就能輕鬆地將它變成一個無線路由器(WiFi熱點),供其他有 Wifi 的電腦或手機共用上網了!真可謂是一人上網,全體受益啊……關於 Maryfi
Time of Update: 2018-12-04
上一篇講述了設定檔的整體結構,下面重點分析htt_core模組的配置資訊結構,得到如下的一幅圖:從上面很明顯可以看出需要合并的ngx_http_core_srv_conf_t、ngx_http_core_loc_conf_t結構體。但是ngx_http_merge_locations代碼中有:for (q = ngx_queue_head(locations); q != ngx_queue_sentinel(locations); q =
Time of Update: 2018-12-04
ubuntu和Win7的雙系統,不知怎麼搞成了“error: unknown filesystem grub rescue:”,使用以下的方法:http://www.cnblogs.com/samcn/archive/2011/03/30/1999615.html1. 先使用ls命令,找到Ubuntu的安裝在哪個分區: grub rescue>ls 會羅列所有的磁碟分割資訊,比方說:
Time of Update: 2018-12-04
前面我們說過,對於靜態檔案的傳輸,用sendfile可以減少系統調用,現在我們看看動態資料應該如何處理。首先,如果資料足夠小(小於1024)且只有唯一的一個buffer,我們直接用 send/write 就可以了。通常的情況下,程式可能會在多個地方產生不同的buffer,如
Time of Update: 2018-12-04
由於這篇博文 http://blog.csdn.net/gsnumen/article/details/7979484?reload 已經分析的很清楚了,我只想自己整理一下:使用 UNIX域通訊端 socketpair() 非同步通訊機制:nginx在建立worker前將先調用 socketpair(int channel[2]) ,然後將
Time of Update: 2018-12-04
這題我是用dp過的,回頭看了網上的資料,可以用談心。再想想吧,先儲存以下代碼:/* * zoj_2710.cpp */#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;#defineN210#define INF1e12/* * dp[i][x][y]: The
Time of Update: 2018-12-04
逾時重傳是TCP協議保證資料可靠性的一個重要機制,其原理是在發送一個資料以後就開啟一個計時器,在一定時間內如果沒有得到發送資料報的ACK報文,那麼就重新發送資料,直到發送成功為止。這是資料包丟失的情況下給出的一種修補機制。一般來說,重傳發生在逾時之後,但是如果發送端接收到3個以上的重複ACK,就應該意識到,資料丟了,需要重新傳遞。這個機制不需要等到重傳定時器溢出,所以叫做快速重傳,而快速重傳以後,因為走的不是慢啟動而是擁塞避免演算法,所以這又叫做快速恢複演算法。快速重傳和快速恢複旨在:快速恢複丟
Time of Update: 2018-12-04
這題Dp方程很容易想到,但是居然WA了一天,後來一個部落格,才發現負數對最大值的影響。恍然大悟呀……/* * zoj_2626.cpp */#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define N52#define hpmax(a,b)(a)>(b)?(a):(b)#define
Time of Update: 2018-12-04
SplayTree 伸展樹:自調節的二叉搜尋樹,能把最近訪問的節點移到根節點出。適用於各種實際應用,尤其適合實現cache和garbage collection演算法。空間少,效能平攤也有競爭力,編程易實現。優點:1、 實現簡單,比AVL、紅/黑樹狀結構更簡單。2、 效能好,平均效能比得上其他平衡二叉搜尋樹。可能會比AVL慢點。常數因子的差距。3、 沒有其他的記錄資料。4、 可以適用於相同鍵的資料,平攤仍然是O(lgn)。類似於穩定排序演算法。缺點:1、
Time of Update: 2018-12-04
運算式模板,在《c++ template》中是為了同時支援數組操作的優雅性和高效性,並說,metaprogramming主要適用與小的大小固定的數組,而expression templates適用於中性和大型數組的運行期操作。但實際上,經過我的測試,元編程和運算式模板不像書中說的那麼神奇,或許,是我沒有實現好。下面,我將測試expression templates。 如果要支援如下的操作:Array<double> x(1000), y(1000)
Time of Update: 2018-12-04
測試平台,Ubuntu 12.04--x64 代碼如下:#include <iostream>#include <cstdio>using namespace std;class A {public: long a; virtual void a1() { cout << "A:a1()" << endl; } virtual void a2() { cout << "A:a2()" << endl; }}
Time of Update: 2018-12-04
TopCoder SRM287 DIV2 Reportmatch date:Saturday, February 4, 2006report date:Thursday, February 09, 2006 Preface: 這是第一次參加TopCoder,手法比較生疏。雖然三題都是趕在結束前提交的,但準確率很低,所以不但給了別人一次challenge,而且System
Time of Update: 2018-12-04
這題明顯是貪心的策略,但是排序演算法一直沒寫好,費了我幾個小時。後來發現,有個部落格http://ppcool.iteye.com/blog/1731427 裡面的排序好簡單呀,好受打擊。回宿舍繼續舔傷口。/* * pat_1038.cpp */#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace
Time of Update: 2018-12-04
在網上找了一些資料,瞭解了一下c++的記憶體配置機制。 注意,我們要區分幾個容易混淆的關鍵詞:new運算式、operator new、placement new 。 operator new 和 operator delete 函數是標準庫函數。當使用 string * sp = new string("hello") ; 時,實際上發生三個步驟:首先,該運算式調用名為 operator
Time of Update: 2018-12-04
最近在學習單調桟,這個題目聽有意思的,需要稍微動動心思,往poj 2559上想。但是時間總是1700MS左右,真不知道網上那些100ms是怎麼出來的。/** * poj_3494.cpp * */#include <iostream>#include <cstdio>#include <cstring>using namespace std;#defineMN2010#define hpmax(a,b)((a)>(b)?(a):(b))#
Time of Update: 2018-12-04
最近想鑽研一下STL原始碼,於是照著侯捷的《STL源碼剖析》看SGI STL,今天想寫寫list的排序演算法。原始碼如下: template <class _Tp, class _Alloc> template <class _StrictWeakOrdering>void list<_Tp, _Alloc>::sort(_StrictWeakOrdering __comp){ // Do nothing if the list has
Time of Update: 2018-12-04
為什麼說B+-tree比B 樹更適合實際應用中作業系統的檔案索引和資料庫索引?1) B+-tree的磁碟讀寫代價更低 B+-tree的內部結點並沒有指向關鍵字具體資訊的指標。因此其內部結點相對B 樹更小。如果把所有同一內部結點的關鍵字存放在同一盤塊中,那麼盤塊所能容納的關鍵字數量也越多。一次性讀入記憶體中的需要尋找的關鍵字也就越多。相對來說IO讀寫次數也就降低了。