Time of Update: 2018-12-04
/*Queue.h -- 隊列標頭檔*/#include "Head.h"/*介面函式宣告*//*操作:建立並初始化一個隊列*//*操作前:pq 指向一個隊列*//*操作後:如果記憶體配置成功, 建立並初始化該隊列, 返回 TRUE ; 否則返回 FALSE*//*時間複雜度:O (1)*/BOOL Initialize_Q (Queue * const pq) ;/*操作:確定一個隊列是否為空白*//*操作前:pq 指向一個已初始化的隊列*//*操作後:如果該隊列為空白, 返回 TRUE ;
Time of Update: 2018-12-04
//Chessboard.cpp#include "stdafx.h"#include "Chessboard.h"//private:int Chessboard ::m_weightValue (void){int weightValue = rand() % m_aLargeWeightValue - (m_aLargeWeightValue >> 1) ;return weightValue ;}int Chessboard ::m_absoluteValue
Time of Update: 2018-12-04
看數學書看到的.居然還是某年的軟考程式員下午題.很輕鬆地寫出來了,挺有意思.//solveEquation.cpp -- 2011-07-19-01.05#include <iostream>#include <cmath>double absoluteValue (const double valA, const double valB) ;double equation (const double x) ;double solveEquation
Time of Update: 2018-12-04
<<演算法導論>>裡面的一道題.今天上午看的東西. 逆序對,舉個例子,A[0] > A[1],則A[0]和A[1]是一對逆序對.呵呵.按照書上所說,用歸併排序實現.我給實現了. 思路很清晰,很享受研究演算法的過程./*2-4-11-04-06-13.16.c -- 第二章第四題*/#include <stdio.h>#include <stdlib.h>#define SIZE (27)int main (void) ;int
Time of Update: 2018-12-04
這個東西,是新學的.上一本書雖然有學過圖,但是,這個問題還是沒有學到,這一次,學到了.前前後後2天,寫出來了. 最近的主要精力在C++與<<Windows via>> 還有 線性代數,演算法的東西實在是前進得不多. 還好,通過今天上午的努力,知道自己的腦袋,還沒有退化.真的,每次實現了一個演算法,都興奮得不得了,確實啊,呵呵.//graph.cpp#include "stdafx.h"#include
Time of Update: 2018-12-04
這東西,昨天寫的.比較欣賞的地方就是,原地實現了迴圈隊列.很清晰,很好的思想./*12-34-11-04-05-19.32.c -- 第十二章第三十四題*/#include "PairingHeap.h"static Node * combineSiblings_P (Node * firstSibling){static Node * treeArray[MAXSIBLINGS] ;static Node * first, * second ;int numSiblings ;int
Time of Update: 2018-12-04
用了類模板,不知是不是多此一舉,反正練習為主.//graphRepresentAsAdjacentMatrix.h --graph header file.//Purpose://A graph represent as a adjacent matrix, this graph can't storage //weight value instead of true or false means m_matrix[i][j] is on or off.#ifndef
Time of Update: 2018-12-04
<<演算法導論>>上的一道思考題,昨天實現的.用到了優先隊列.鏈表我給實現成了隊列的方式,比較習慣這樣.呵呵. 在這個標頭檔中,定義了兩個資料結構的資料類型和宏,這是第一次嘗試.中途遇到過問題,
Time of Update: 2018-12-04
//graph.cpp -- implement file.//2011-09-25-14.31 -- 2011-09-25-15.58//2011-09-25-18.16 -- 2011-09-25-20.00//2011-09-26-17.20 -- 2011-09-26-18.04//2011-09-26-19.19 -- 2011-09-26-20.00//2011-09-27-09.06 -- 2011-09-27-09.57template<class T>void
Time of Update: 2018-12-04
最大流演算法.在有向圖上啟動並執行演算法.在出現演算法介紹之前,先給出了各種概念.殘餘網路,增廣路徑,割.實現很直觀,用到了廣度優先搜尋.O(VE)的已耗用時間. 演算法的分析與證明我沒有關注,呵呵.//Edmonds-Karp.cpp#include "stdafx.h"#include "graph.h"#include <iostream>#include <vector>using std ::vector ;typedef int T ;const
Time of Update: 2018-12-04
以下所討論,都是C++中的概念. 編譯代碼的時候,在符號表中,引用的地址是引用的變數的地址,指標的地址,是指標自身的地址.也就是說,引用本質上是不存在的,而指標是確實存在的.int a = 1 ;int & reference = a ;int * pointer = &a
Time of Update: 2018-12-04
看代碼吧.同樣是昨天實現的東西./*2011-04-12-18.00.c -- 探尋聯合*//*Suppose current machine works as little endian.*/#include <stdio.h>union U{char array[4] ;int value ;} ;/*<-Be careful!*/int main (void) ;int main (void){union U test ;/*0000
Time of Update: 2018-12-04
在小端法的機器上,兩個 short int 分別將各自的最低有效位元組存放在各自起始地址最左邊(下文簡稱起始地址為地址).需要說明的是:雖然每個 short int 是依據小端法儲存各自的每個位元組,但是兩個 short int 之間資料是順序儲存的., 在 float 取得資料的時候,獲得兩個 short int 的位元模式.同時將地址最左面的位元組作為自己的最低有效位位元組.簡單說來就是: 資料的最低有效位元組儲存在最左邊 <=>
Time of Update: 2018-12-04
探尋本機是小端法機器,還是大端法機器.這東西,半年前就見過,直到昨天才去實現.恩.貼代碼吧./*2011-04-12-16.40.c -- 探尋大端法與小端法*/#include <stdio.h>int main (void) ;int main (void){int test ;char * address ;test = 0x01020304 ;address = &test ;if (4 == *address)/*0100001100100001*/puts (
Time of Update: 2018-12-04
這個東西,實在實在是說不好.在前一段的時候,考慮別的問題的時候想到這個問題.自己研究了下,又上網看了一下,總算是有了個結果.至於更深入的,也沒有去考慮.這個死角,觸到了就好. 最近重點Win32API,演算法方面內容不多.不過,過一陣應該會多起來吧. 貼.// wholePermutation.cpp -- 2011-07-16-13.43#include "stdafx.h"#include <iostream>const int SIZE = 4 ;//Use
Time of Update: 2018-12-04
呼,從12月開始,開始學習,使用C#了.還好自己之前是學過C和C++,學起來不那麼困難.特性很多,沒有貪多地去掌握. 在項目裡,暫時沒有我什麼事,自己在那,學習引擎,看服務端和用戶端的代碼.每天就是自己給自己找事情做,不然就會枯燥.有的時候啊,會比較悶的,忍咯,比從前的日子還是好過度多了. 這種程式,很久以前寫過一個.是用C寫的.這個呢,是C#,比C的功能多了許多.這個語言還是不錯,純物件導向.
Time of Update: 2018-12-04
在將各種類型的資料構造成字串時,sprintf 的強大功能很少會讓你失望。由於sprintf 跟printf 在用法上幾乎一樣,只是列印的目的地不同而已,前者列印到字串中,後者則直接在命令列上輸出。這也導致sprintf 比printf 有用得多。sprintf 是個變參函數,定義如下:int sprintf( char *buffer, const char *format [, argument] ... );除了前兩個參數類型固定外,後面可以接任意多個參數。而它的精華,顯然就在第二個參數:
Time of Update: 2018-12-04
using System;using System.Collections;public class Test{ static public Action A; static public Action<int> B; static public Action<int, string> C; static public Action<int, string, int> D; static public Action<int,
Time of Update: 2018-12-04
為使用malloc分配空間時報錯,錯誤碼如下:malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) – __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >=
Time of Update: 2018-12-04
規律:1). 每一個成員的地址能夠被它本身位元組數整除; 2). 最後總的位元組數必須能夠被最大位元組數的成員整除; 3). 一般可以以地址0為起始地址來考慮。否則的話就會產生補位。例如:typedef struct test {char a; //2bytesint b; //1byteschar d[21]; //20bytesdouble f;};結果sizeof(test)=4。實際上,1