<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 問題描述 > 設一個帶表頭結點的單鏈表中所有元素結點的數據值無序,試編寫一個函數,刪除表中所有其值在給定值s與t之間(包含s和t,要求s<t)的所有結點 ## 算法思想 > 因為鏈表邏輯上無序,刪除指定區間結點的前提是找到這些指定區間結點。因此從頭節點開始對整個鏈表進行一次遍歷,若找到滿足題意的結點,刪除即可。 ## 算法描述 ~~~ void Delts(LNode* head, ElemType t, ElemType s) { LNode *pre=head; LNode *p=head->next; while(p){ if(p->data>s&&p->data<t){ pre->next=p->next; free(p); p=pre->next; }else{ pre=p; p=p->next; } } } ~~~ 具體代碼見附件。 ## 附件1 ~~~ #include<stdio.h> #include<stdlib.h> typedef int ElemType; typedef struct LNode{ ElemType data; struct LNode *next; }LNode, *Linklist; Linklist CreatLNode(LNode*); void Delts(LNode*, ElemType, ElemType); void Print(LNode*); int main(int argc,char* argv[]) { LNode *head; head=(LNode*)malloc(sizeof(LNode)); head->next=NULL; head=CreatLNode(head); Print(head); ElemType t=7; ElemType s=3; Delts(head, t, s); Print(head); return 0; } //頭插法創建單鏈表 Linklist CreatLNode(LNode* head) { LNode *L; ElemType x; scanf("%d",&x); while(x!=999){ L=(LNode*)malloc(sizeof(LNode)); L->data=x; L->next=head->next; head->next=L; scanf("%d",&x); } return head; } //查找并刪除指定區間結點 void Delts(LNode* head, ElemType t, ElemType s) { LNode *pre=head; LNode *p=head->next; while(p){ if(p->data>s&&p->data<t){ pre->next=p->next; free(p); p=pre->next; }else{ pre=p; p=p->next; } } } //打印所有結點 void Print(LNode *head) { LNode *p=head->next; while(p){ printf("%4d",p->data); p=p->next; } printf("\n"); } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看