資料結構實驗之鍊表三 鍊錶的逆置

2021-08-17 14:18:26 字數 772 閱讀 5166

time limit: 1000 ms

memory limit: 65536 kib 、

problem description

輸入多個整數,以-1作為結束標誌,順序建立乙個帶頭結點的單鏈表,之後對該單鏈表的資料進行逆置,並輸出逆置後的單鏈表資料。

input

輸入多個整數,以-1作為結束標誌。

output

輸出逆置後的單鏈表資料。

sample input

12 56 4 6 55 15 33 62 -1

sample output

62 33 15 55 6 4 56 12

#include

#include

struct node

*head;

struct node *creat()

p = (struct node *)malloc(sizeof(struct node));

p-> data = n;

p-> next = null;

tail-> next = p;

tail = p;

}return head;

}struct node *deverse(struct node *head)

}return head;

}void print(struct node *head)

else

p = p-> next;}}

int main(void)

資料結構實驗之鍊表三 鍊錶的逆置

time limit 1000ms memory limit 65536k 輸入多個整數,以 1作為結束標誌,順序建立乙個帶頭結點的單鏈表,之後對該單鏈表的資料進行逆置,並輸出逆置後的單鏈表資料。輸入多個整數,以 1作為結束標誌。輸出逆置後的單鏈表資料。12 56 4 6 55 15 33 62 1...

資料結構實驗之鍊表三 鍊錶的逆置

資料結構實驗之鍊表三 鍊錶的逆置 輸入多個整數,以 1作為結束標誌,順序建立乙個帶頭結點的單鏈表,之後對該單鏈表的資料進行逆置,並輸出逆置後的單鏈表資料。輸入多個整數,以 1作為結束標誌。輸出逆置後的單鏈表資料。12 56 4 6 55 15 33 62 1 62 33 15 55 6 4 56 1...

資料結構實驗之鍊表三 鍊錶的逆置

time limit 1000ms memory limit 65536k 輸入多個整數,以 1作為結束標誌,順序建立乙個帶頭結點的單鏈表,之後對該單鏈表的資料進行逆置,並輸出逆置後的單鏈表資料。輸入多個整數,以 1作為結束標誌。輸出逆置後的單鏈表資料。12 56 4 6 55 15 33 62 1...