6 13 刪除單鏈表偶數節點 20 分

2021-09-20 02:51:31 字數 928 閱讀 2803

本題要求實現兩個函式,分別將讀入的資料儲存為單鏈表、將鍊錶中偶數值的結點刪除。鍊錶結點定義如下:

struct listnode ;

函式介面定義:

struct listnode *createlist();

struct listnode *deleteeven( struct listnode *head );

函式createlist從標準輸入讀入一系列正整數,按照讀入順序建立單鏈表。當讀到−1時表示輸入結束,函式應返回指向單鏈表頭結點的指標。

函式deleteeven將單鏈表head中偶數值的結點刪除,返回結果鍊錶的頭指標。

裁判測試程式樣例:

#include

#include

struct listnode ;

struct listnode *createlist();

struct listnode *deleteeven( struct listnode *head );

void printlist( struct listnode *head )

printf(」\n");

}int main()

else

tail = p;

scanf("%d",&data); }

return head;

}struct listnode *deleteeven( struct listnode *head )

if (head == null)

return null;

ptr1 = head;

ptr2 = head->next;

while (ptr2 != null)

else

ptr1 = ptr2;

ptr2 = ptr1->next;

}return head;

}

刪除單鏈表偶數節點 20分

本題要求實現兩個函式,分別將讀入的資料儲存為單鏈表 將鍊錶中偶數值的結點刪除。鍊錶結點定義如下 struct listnode 函式介面定義 struct listnode createlist struct listnode deleteeven struct listnode head 函式cr...

實驗11 2 4 刪除單鏈表偶數節點 20分

本題要求實現兩個函式,分別將讀入的資料儲存為單鏈表 將鍊錶中偶數值的結點刪除。鍊錶結點定義如下 struct listnode struct listnode createlist struct listnode deleteeven struct listnode head 函式createlis...

資料結構 刪除單鏈表偶數節點

本題要求實現兩個函式,分別將讀入的資料儲存為單鏈表 將鍊錶中偶數值的結點刪除。鍊錶結點定義如下 struct listnode 函式介面定義 struct listnode createlist struct listnode deleteeven struct listnode head 函式cr...