oblem description
輸入多個整數,以-1作為結束標誌,順序建立乙個帶頭結點的單鏈表,之後對該單鏈表的資料進行逆置,並輸出逆置後的單鏈表資料。
input
輸入多個整數,以-1作為結束標誌。
output
輸出逆置後的單鏈表資料。
input
12 56 4 6 55 15 33 62 -1
sample output
62 33 15 55 6 4 56 12
hint
不得使用陣列。
#include
using
namespace std;
struct node
;int
main()
tail=head-
>next;
p=tail-
>next;
head-
>next=
null
;while
(tail)
tail=head-
>next;
while
(tail!=
null
)return0;
}
鍊錶的逆置
5.鍊錶的逆置 已知head指向乙個帶頭節點的單向鍊錶,鍊錶中每個結點包含資料域和指標域。用鍊錶實現該鍊錶的逆置,並輸出。例如 輸入 5 整數表示要輸入的字元個數 abcde 輸出 edcba 注意 不允許通過改變每個節點的資料域來實現效果,必須改變鍊錶連線順序發生逆置。我寫的 如下 include...
鍊錶的逆置
剛剛除錯出來,趁熱寫一下。輸入多個整數,以 1作為結束標誌,順序建立乙個帶頭結點的單鏈表,之後對該單鏈表的資料進行逆置,並輸出逆置後的單鏈表資料。input 輸入多個整數,以 1作為結束標誌。output 輸出逆置後的單鏈表資料。sample input 12 56 4 6 55 15 33 62 ...
鍊錶之鍊錶的逆置
題目 資料結構實驗之鍊表三 鍊錶的逆置 time limit 1000 ms memory limit 65536 kib submit statistic discuss problem description 輸入多個整數,以 1作為結束標誌,順序建立乙個帶頭結點的單鏈表,之後對該單鏈表的資料進...