本題要求實現乙個函式,將給定單向鍊錶逆置,即表頭置為表尾,表尾置為表頭。鍊錶結點定義如下:
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 tail;
}
6 27 鍊錶逆置 20分
本題要求實現乙個函式,將給定單向鍊錶逆置,即表頭置為表尾,表尾置為表頭。鍊錶結點定義如下 struct listnode struct listnode reverse struct listnode head 其中head是使用者傳入的鍊錶的頭指標 函式reverse將鍊錶head逆置,並返回結果...
鍊錶逆置 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逆...