原创 JS----日期對象

獲取日期對象中的指定部分,js1.6開始加入toLocaleFormat的方法,但是IE只支持JS1.3,所以不支持此方法: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitiona

原创 HDU 3038 how many answers are wrong(帶權並查集)

很簡單的題,找出各個節點與根節點的關係,並與輸入的權值進行比較 #include<iostream> using namespace std; #define MAX 200005 struct num { int father;

原创 2個有序鏈表的合併

#include<iostream> using namespace std; typedef struct head { int a; struct head *next; }NLode; void intial(NLode *

原创 js------數組

添加數組元素方法: unshift(); push(); splice(index,0,E1,E1,..........)          //the second paremeter must be o <!DOCTYPE html

原创 POJ 1733 parity game (hash離散+並查集)

題目要求輸入的長度less or equal 1000000000,但是實際的問題數卻小於5000 所以我們考慮hash離散化。 解題思路如下: 我們爲每一個輸入的點,建立struct,內包含2個成員,father指向父親node

原创 帶頭結點鏈表的實現

#include<iostream> using namespace std; typedef struct head { int a; struct head *next; }NLode; void intial(NLode *

原创 深入理解操作系統的管程,進程,線程(二)

1.進程間的通信(inter-process communication,IPC) 有三點需要注意: 一:一個作業通常被分爲若干個能併發執行的進程 二:這些進程以各自獨立的速度向前推進,但是他們能保持通信,以便協調一致的(同步)完成任務。

原创 linux進程控制---wait()使用方法

1.wait不帶參數的使用 進程調用wait()後,就堵塞了自己,直到檢測到當前進程的某個子進程已經退出。 如果堅持成功,則會返回該進程的ID。如果進程沒有子進程,則會返回-1。 它是這樣定義的。 #include<sys/types.

原创 鏈表的冒泡排序

#include<iostream> using namespace std; typedef struct head { int a; struct head *next; }NLode; void intial(NLode *

原创 HDU 1233 (最小生成樹) 用並查集實現kruskal

題目很簡單,不過有些細節要注意 #include<iostream> #include<algorithm> using namespace std; #define MAX 10000 struct edge1 { int x,y;

原创 鏈表翻轉

#include<iostream> using namespace std; typedef struct head { int a; struct head *next; }NLode; void intial(NLode *

原创 深入理解l操作系統的管程,進程,線程(一)

1.管程(monitors)和定義 P,V操作分散在用戶程序中,系統無法有效的控制盒管理,而且P,V操作使用不當還會引起系統的死鎖,所以產生了新的進程同步工具-------管程。 代表共享資源的數據結構,以及對該共享數據結構實施操作的一組

原创 如何求二叉樹的高度(遞歸實現)

核心代碼 比較左右子樹的高度,把高的那個子樹+1返回,就是整棵樹的高度 int Height(BiTreeNode *head) { if(head==NULL) return 0; else { int m=Height(h

原创 linux下VIM編譯器的使用

打開terminal終端,然後輸入 vim  test.c 按“a”進入insert模式 輸入如下程序: #include<stdio.h> void main() { printf("hello world\n"); }

原创 二叉樹的創建和前序,中序,後序遍歷

第一種寫法: 使用指針的指針初始化 #include<iostream> #include<assert.h> using namespace std; typedef struct Lnode { char data; str