鍊錶逆置 20分

2021-10-03 06:39:42 字數 695 閱讀 2580

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

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 news;

}

6 27 鍊錶逆置 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逆置,並返回結果...

6 4 鍊錶逆置 20分

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