返回列表 發帖

[作業]APCS 觀念題 10503 - 6

本帖最後由 李泳霖 於 2021-12-25 10:39 編輯

List是一個陣列,裡面的元素是 element, 它的定義如右。

List 中的每一個 element 利用next 這個整數變數來記錄下一個 element在陣列中的位置,如果沒有下一個 element,next 就會記錄-1。所有的 element 串成了一個串列 (linked list)。例如在 list 中有三筆資料
它所代表的串列如下圖

RemoveNextElement 是一個程序,用來移除串列中current 所指向的下一個元素,但是必須保持原始串列的順序。例如,若current 為3 (對應到 list[3]),呼叫完RemoveNextElement 後,串列應為
  1. struct element
  2. {
  3.       char data; int next;
  4. }
  5. void RemoveNextElement (element list[], int current)
  6. {
  7.       if (list[current].next != -1)
  8.       {
  9.             /*移除 current 的下一個 element*/

  10.            ______________________________
  11.       }
  12. }
複製代碼
請問在空白部分,應該填入的程式碼為何?

(A) list[current].next = current ;
(B) list[current].next = list[list[current].next].next ;
(C) current = list[list[current].next].next ;
(D) list[list[current].next].next = list[current].next ;

本帖隱藏的內容需要回復才可以瀏覽

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見
Vincent

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

返回列表