回覆列表
  • 1 # 使用者6354188383803

    //create an orderedly single-liked list

    template

    void slist

    { Node

    newnode=new Node

    //find inserting positon

    preptr=NULL;

    currptr=head;

    while(currptr!=NULL)

    { if (item

    break;

    preptr=currptr;

    currptr=currptr->next;

    }

    //make the insertion

    if(preptr==NULL) //insert into the head of the linked list

    { newnode->next=head;

    head=newnode;

    }

    else //insert into middle of the linked list

    { newnode->next=currptr;

    preptr->next=newnode;

    }

    }

    //newnode相當於你提問的x

  • 中秋節和大豐收的關聯?
  • 寶藍色與什麼顏色搭配?