雙迴圈鍊錶

2022-07-31 07:00:17 字數 1223 閱讀 6999

#include#include #include #include #include #include using namespace std;

typedef int elemtype;

typedef struct node

linknode,*linklist;

//鍊錶初始化

linklist initlinklist()

head->next=head;

head->pre=head;

printf("鍊錶初始化成功!\n");

return head;

}//建立結點

linklist createnode(int val)

//尾插法

void insertlinklistbynext(linklist l,int x)

l->pre = newnode;

newnode->next = l;

lastnode->next = newnode;

newnode->pre = lastnode;

}//頭插法

void insertnodebyhead(linklist headnode,int data)

//正序輸出

void printlist(linklist l)

printf("\n");

} //逆序輸出

void printlist_reverse(linklist l)

printf("\n");

} //查詢指定元素

void searchelement(linklist l,int x) }

printf("該元素存在!\n");

} //查詢指定元素並更改

void modifyelement(linklist l,int x,int elem)

} posnode->data = elem;

printf("修改成功!\n");

}

//刪除指定元素

void specify(linklist headnode,int posdata)

} posnodeprior->next = posnode->next;

posnode->next->pre = posnodeprior;

free(posnode);

}int main()

雙迴圈鍊錶

nyoj511移動小球 include include typedef struct node lnode 結點 lnode creat list lnode head,int num 建立不帶頭結點的雙迴圈鍊錶 current data i current rear current pre nul...

雙迴圈鍊錶的相關演算法

include include using namespace std typedef int elemtype typedef struct node nodetype nodetype create return head void dis nodetype head while p head ...

資料結構(C ) 雙迴圈鍊錶

include allhead.h templateclass dblist templateclass dblistnode dblistnode t x,dblistnode pt null,dblistnode nt null templateclass dblist dblist statu...