Time of Update: 2018-12-04
這東西,有隨機化演算法的影子.使得每個結點以 priority 值保持堆序,繼而實現對樹高度的控制.想法很好,實現起來也很簡單./*treapTree.h -- treap樹標頭檔*/#include <stdio.h>#include <stdlib.h>#include <time.h>#define INFINITY (~(1 << 31))typedef int Item ;typedef struct node{Item item ;
Time of Update: 2018-12-04
文章目錄 先來一個簡單的例子 來一個真正意義上的 C++ 程式,且使用 SEH 機制 總結 轉載自http://blog.programfan.com/article.asp?id=9864首先聲明的是, C++ 中的異常處理機制是建立在 Windows 平台上的 SEH 機制之上,所以 SEH 當然可以在 C++ 程式中使用。不過“阿愚”多次強調過,我們平常一般狹義上的 SEH 都是指 try-except 和 try-finally
Time of Update: 2018-12-04
/*7-11-11-19-22.12.c -- 第七章第十一題*/#include <stdio.h>#include <stdlib.h>#define LEFTCHILD(position) ((position) * 2 + 1)/*Notice the space*/#define SIZE 12int main (void) ;void print_array (const int * const array, const int size) ;void
Time of Update: 2018-12-04
看<<AtA>>,一道題.尾遞迴,迴圈換遞迴.思想很好,用處很大. 沒有華麗的效能提高,只是展現尾遞迴的思想.確實,快速排序我還並未搞懂.先繼續進行吧. 貼~/*2011-04-20-21.32.c -- 快速排序尾遞迴版*/#include <stdio.h>#include <stdlib.h>#define SIZE (22)int main (void) ;void printArray (const int * const
Time of Update: 2018-12-04
不同於路徑壓縮,偏路徑壓縮使得訪問路徑上的節點整體向上移動.很好./*8-14-12-03-00.30.c -- 第八章第十四題*/SetType Find (DisjiontSet gather, const Item item) ;SetType Find (DisjiontSet gather, const Item item){Item temp, i, j ;if (gather[item] < 0)return item ;i = gather[item] ;while (
Time of Update: 2018-12-04
一晃又是好幾天.總算今天是有代碼出現了. 自頂向下伸展樹,比去年寫的那個伸展樹輕鬆多了. 人家總結出來的東西,我看懂了,完全讓我自己寫的話,很難啊. 這段代碼,有些技巧.說的就是"NullNode"到底是怎麼回事,具體的自己看代碼吧.而且,發現自己的C語言功底還不夠,自己補了下,而且接下來會有意識地學一學了. 不多說了.還有,下周去報名,程式員考試.我幹勁. /*SplayTree.h -- 自頂向下伸展樹標頭檔*//*酒後寫的標頭檔哦.*/#include <stdio.h&
Time of Update: 2018-12-04
確定一棵樹流出的最大流,即樹葉可以流入的最大流量的和,也就是整棵樹流出的流量. 樹中每一個非分葉節點的流出流量 = min (流入流量, 路徑容量). 知道了這些,自然的方式使用遞迴,就可求解出該問題. 很遺憾,我是在看了答案之後才寫出的這些./*9-12-12-15-15.53.c -- 第九章第十二題*//*Pseudocode*/FlowType FindMaxFlow (const Tree T, FlowType IncomingFlow) ;FlowType
Time of Update: 2018-12-04
/*disjiont_set.c -- 不相交集合實現檔案*/#include <stdio.h>#include <stdlib.h>#include "disjiont_set.h"/*介面函數定義*/int Initialize_D (Disjiont d, const int capacity){int i ;if (capacity <= 0)return 0 ;d[0] = capacity ;for (i = 1 ; i <= capacity;
Time of Update: 2018-12-04
/*10-5-11-01-11-21.47.c-- 第十章第五題*/#include "Uiversal_queue.h"typedef struct data{int time ;int count ;} Data ;int main (void) ;int showMenuAndGetChoice (void) ;void eatLine (void) ;int getInput (int * const input, const int size) ;Data nextFit
Time of Update: 2018-12-04
反轉一個鄰接表,沒有考慮權值.是為另一個常式服務的一個函數.貼出來吧.int Reverse_A (Adjacenty_List * const padj, const Hash_Table * const pht){Name name ;Adjoin_To_Vertex * scan, * new_vertex, * temp_1, * * temp_2 ;int w, i, capacity = (*padj) -> capacity ;for (i = 0; i <
Time of Update: 2018-12-04
最近的代碼產量好低,讓我很有罪惡感!到家老是想睡覺,感覺很累.也確實,最近確實很累.也可能是因為,自己老是這麼認為,才會去累的吧... 需要調整調整,各種調整.畢竟,想墮落是很容易的. 這段代碼,寫了3天多.畢竟,動態規劃給我帶來的陰影還是很大的.最近研究演算法,搞得自信下去了.還好了,這段代碼,及時出現了. 對於隨機函數,我的使用,很爛,希望以後有改進. 帖!/*SkipList.h -- 跳躍表標頭檔*/#include <stdio.h>#include
Time of Update: 2018-12-04
話說這個東西,寫了不下12小時.我堅持寫完了,並且寫對了.我很高興. 通過寫這個東西,加強了對尋找割點問題的認識,從而認識,並明白了尋找雙連通分支的過程. 我想要說明的是,深度優先搜尋,深度優先.從 (v, w) 開始的深度優先搜尋, 在回到調用 (v, w) 的那次調用之前, (w, v) 已經被處理過.這保證一條邊不會入棧兩次.同時, 也同時可以避免已被作為背向邊處理的 (v, w) 入棧.這都是通過 if (!Find_L (pli, w, index)) 來實現的.
Time of Update: 2018-12-04
對於這個,想說的是.關於 NullNode 結點.在調用Release ()釋放記憶體之後,要將其恢複為NULL,以便下次的連續使用.自己想到的,很不錯./*treap.c -- treap樹實現檔案*/#include "treapTree.h"/*全域變數聲明定義*/static Node * NullNode = NULL ;/*局部函式宣告*/static Node * singleRotateWithLeft (Node * const pn) ;static Node *
Time of Update: 2018-12-04
合并兩個文字檔,這個思想很不錯,我很喜歡./*7-37-11-27-22.11.c -- 第七章第三十七題*/#include <stdio.h>int main (void) ;int main (void){FILE * fpa, * fpb, * fpc ;char cha, chb ;fpa = fopen ("a.txt", "r") ;fpb = fopen ("b.txt", "r") ;fpc = fopen ("c.txt", "w") ;if (NULL ==
Time of Update: 2018-12-04
/*Uiversal_queue.h -- 隊列標頭檔*/#include "Head.h"/*Define data type*/typedef struct node{Item item ;struct node * next ;} Node ;typedef struct queue{Node * front ;Node * rear ;int current ;} * Queue ;/*Proclaim interface functions*/Bool Initialize_Q
Time of Update: 2018-12-04
//graphRepresentAsAdjacentList.h -- graph header file.//2011-08-28-20.26 -- //Purpose://Define a class "graphRepresentAsAdjacentList".//Declare methods of the class, and define element member.#include <iostream>#include <vector>#include
Time of Update: 2018-12-04
不得不感歎一下天下代碼一大抄,到百度上一搜,結果都是如下的代碼。[STAThread] static void Main() { //只允許運行一個程式 bool createNew; System.Threading.Mutex mutex = new System.Threading.Mutex (true, "Global\\" +
Time of Update: 2018-12-04
#include <windows.h>#include <iostream.h>/*功能:使檔案開機自動運行思路:擷取檔案的路徑,將檔案拷貝到系統檔案夾之下;在註冊表中註冊檔案路徑,使其開機自動運行。提示:如果要隱藏,另外可以在以上執行完畢之後,刪除原始檔案.當然,還可以通過註冊程式為系統服務,使其開機自動運行.刪除:在執行程式之後,執行以下操作,使系統復原原狀:1. 刪除 C:\WINDOWS\system32\yourvirus.exe2. 開啟註冊表:
Time of Update: 2018-12-04
http://www.vcworld.net/news/200911/091956.html 1、現將二各函數sub1()及sub2()建立成一個函數庫檔案取名為mylib.lib。兩個函數的函數及型參如下:void sub1(void);float sub2(int i,float
Time of Update: 2018-12-04
http://zhidao.baidu.com/question/80154230.html?fr=qrl&cid=866&index=4 能,找本sql方面的書看看,跟c語言介面部分。C API代碼是與MySQL一起提供的。它包含在mysqlclient庫中,並允許C程式訪問資料庫。MySQL源碼分發版的很多用戶端是用C語言編寫的。如果你正在尋找能示範如何使用C