原部落格地址:http://blog.chinaunix.net/uid-20551990-id-371961.html近期在看一些筆試面試題,發現很多題目涉及到樹,而其中遞迴演算法在解題中又顯得特別重要,所以轉了一篇文章用來查閱之用。#include <stdio.h>#include <stdlib.h>struct tree{char data;struct tree *lchild;struct tree *rchild;};typedef struct
Rescue LKTime Limit:1000MS Memory Limit:65536KTotal Submit:83 Accepted:42 Descriptionziliang loves LK. But LK was kidnapped by Monster.oyy,and was put in a labyrinth.After thousands of hard fighting, ziliang finally enter the labyrinth. He must
題目:給出一個字串,求該字串的一個子串S,S包含A-Z中的全部字母,並且S是所有合格子串中最短的,輸出S的長度。如果給出的字串中並不包括A-Z中的全部字母。如果無解輸出-1。輸入 串S長度 <= 100000。我的做法:大概做法和我之前做過的一題根本相同,參見這個:字串的故事代碼:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<memory.h>const int
在SDK中最痛苦的事情莫過於訊息一多程式看起來就很亂。不過VC裡有一個windowsx.h的標頭檔,裡麵包含了大部分window訊息的訊息分流器。利用它可以實現用函數在處理訊息。而不是寫一大遝代碼在switch(msg)裡面。上面是傳統的寫法。這是訊息分流器的寫法,以下是他的處理函數在switch語句中,利用了一個HANDLE_MSG的宏,其實它張開後是這樣的這裡面有一個奇怪的東西HANDLE_##message,其實##是連接字串的意思。以WM_CREATE為例,他展開後變成 case
Beautiful SequenceTime Limit:1000MS Memory Limit:65536KTotal Submit:206 Accepted:28 DescriptionA sequence of numbers A[1], A[2], ..., A[N] is beautiful only if each number A[i] ≥ i ( 1 ≤ i ≤ n ). Given a sequence of numbers, your task is to turn it