struct node struct node next typedef struct node Slides: 32 Download presentation 靜態與動態結構 struct _node { 資料型態 變數名稱; struct _node *next; }; typedef struct _node; struct _node * head node 資料型態 struct _node * 資料 NULL n node n; n. next = NULL; node 變數名稱 next 資料型態 struct _node * 資料 NULL 變數名稱 next (malloc) node *head; head = (node *)malloc(sizeof(node)); head->next = NULL; 4 新增節點 動態配置一節點之記憶體 p = (node *) malloc(sizeof(node)); node * p int struct _node * x data x next (malloc) 6 釋放節點 歸還一個節點之記憶體 free(p); node * (malloc) p int struct _node * x data x next (malloc) 7 練習 (建立鏈結串列節點) 建立一個鏈結串列節點結構如下圖所示: struct _node * head int node 10 20 30 data NULL next struct _node * (malloc) 8 刪除節點 狀況二:刪除最後一個節點 head previous … NULL (2) (1) NULL ptr head … NULL 23 Struct node int data struct node* nextNodenextTypedef struct tree int infoTypedef struct tree int infoTypedef struct treeTypedef nodeTypedef struct nodeTypedef struct nodeTypedef struct node int valueNodenextX.next = x.next.nextTypedef struct en cListnodeTypedef struct cHTypedef enumTypedef struct tagTypedef structCopying structs in cC doubly linked listStruct node int dataStruct node int i float jStruct node int i float jRussell-saunders couplingReference node and non reference nodeReference node and non reference nodeTransverse standing wavesC typedef enumTypedef floatTypedef in structureTypedef int elementTypedef boolForward declaration of typedef