在帶表頭且無序的連結串列中刪除屬於給定範圍值的元素
阿新 • • 發佈:2018-12-10
#include "stdafx.h" #include<stdio.h> #include<malloc.h> #include<stdlib.h> typedef int type; typedef struct lnode //定義連結串列結點的資料結構 { int data; struct lnode *next; }Lnode; typedef Lnode node; typedef struct dnode//定義雙鏈表結點的資料結構 { int data; struct dnode *lnext; struct dnode *rnext; }Dnode;
int delvalue7(node *h, type a, type b) { node *h1 = h; while (h1->next != NULL) if (h1->next->data>a&&h1->next->data<b) { node *p = h1->next; h1->next = h1->next->next; free(p); } else h1 = h1->next; return 0; }