實驗11 2 9 鍊錶逆置 20 分

2021-10-19 08:02:12 字數 865 閱讀 9857

本題要求實現乙個函式,將給定單向鍊錶逆置,即表頭置為表尾,表尾置為表頭。鍊錶結點定義如下:

struct listnode 

;

函式介面定義:

struct listnode *

reverse

(struct listnode *head )

;

其中head是使用者傳入的鍊錶的頭指標;函式reverse將鍊錶head逆置,並返回結果鍊錶的頭指標。

裁判測試程式樣例:

#include

#include

struct listnode

;struct listnode *

createlist()

;/*裁判實現,細節不表*/

struct listnode *

reverse

(struct listnode *head )

;void

printlist

(struct listnode *head )

printf

("\n");

}int

main()

/* 你的**將被嵌在這裡 */

輸入樣例:

1 2 3 4 5 6 -1

輸出樣例:

6 5 4 3 2 1

題目集全集傳送門

struct listnode*

reverse

(struct listnode* head)

return heado;

}

實驗11 2 9 鍊錶逆置 20分

本題要求實現乙個函式,將給定單向鍊錶逆置,即表頭置為表尾,表尾置為表頭。函式介面定義 struct listnode reverse struct listnode head 其中head是使用者傳入的鍊錶的頭指標 函式reverse將鍊錶head逆置,並返回結果鍊錶的頭指標。裁判測試程式樣例 in...

鍊錶逆置 20分

本題要求實現乙個函式,將給定單向鍊錶逆置,即表頭置為表尾,表尾置為表頭。鍊錶結點定義如下 struct listnode 函式介面定義 struct listnode reverse struct listnode head 其中head是使用者傳入的鍊錶的頭指標 函式reverse將鍊錶head逆...

6 27 鍊錶逆置 20 分

本題要求實現乙個函式,將給定單向鍊錶逆置,即表頭置為表尾,表尾置為表頭。鍊錶結點定義如下 struct listnode 函式介面定義 struct listnode reverse struct listnode head 其中head是使用者傳入的鍊錶的頭指標 函式reverse將鍊錶head逆...