10 likes | 122 Vues
This assignment requires you to implement a program based on the lecture notes from chapters 1-2, specifically from pages 35-37. You will input at least ten elephant names into your program. Additionally, you need to create a new function called `reverse_elephant`, which takes the starting pointer of a linked list as an argument and returns a new linked list with the elements in reverse order. The function's prototype should be implemented as `Elephant*.reverse_elephant(Elephant*.start)`. To verify your implementation, call `reverse_elephant` at least twice in the main function and confirm the correctness of your linked list operations.
E N D
homework #2 (1). 執行講義chap1-2, p.35-p.37的程式,輸入至少10隻象的名字。 (2). 加入一新的function名為reverse_elephant至(1)程式中,其function prototype如下: Elephant* reverse_elephant(Elephant* start); 此function的功能在於建立一新linked list,將原以start為起點的linked list中的資料做反向連結,然後傳回此新的linked list的起始位置的pointer值 ;並在main function中至少重複呼叫reverse_function兩次,用以驗證你的程式的正確性。例如: 原: start … 經reverse_elephant後: rstart … elp1 elp2 elpn 0 elpn elp2 elp1 0