数据结构
双向链表的建立,删除,插入 #include<stdio.h> #include<string.h> #include<conio.h> #include<iostream> using namespace std; typedef struct student {
int data;
struct student *pre; struct student *next; }dnode;
dnode *create() {
int cycle=1;
dnode *head,*p,*s; int x;
head=(dnode*)malloc(sizeof(dnode)); p=head; while(cycle) {
printf("input data\n"); scanf("%d\n",&x); if(x!=0) {
s=(dnode*)malloc(sizeof(dnode)); s->data=x;
printf("%d\n",s->data); s->pre=p; p->next=s; p=s; } else {
cycle=0; } }
head=head->next; head->pre=NULL; s->next=NULL; return(head); }
int length(dnode *head) {
dnode *p; int n=0; p=head;
while(p!=NULL) {
p=p->next; n++; }
return (n); }
void print(dnode *head) {
dnode *p; p=head;
if(head!=NULL) while(p!=NULL) {
printf("%d ",p->data); p=p->next; }
}//__page_break__
dnode *insert(dnode *head,int num) {
dnode *p0,*p1; p1=head;
p0=(dnode*)malloc(sizeof(dnode)); p0->data=num;
while(p0->data>p1->data && p1->next!=NULL) {
p1=p1->next; }
if(p0->data<=p1->data) {
if(head==p1) {
p0->next=p1; p1->pre=p0; head=p0; } else {
p0->pre=p1->pre; p1->pre->next=p0; p0->next=p1; p1->pre=p0; } } else {
p1->next=p0; p0->pre=p1;
p0->next=NULL; }
return (head); }
dnode *del(dnode *head,int num) {
dnode *p1,*p2; p1=head;
while(num!=p1->data && p1->next!=NULL) {
p1=p1->next; }
if(num==p1->data) if(p1==head) {
head=head->next; head->pre=NULL; free(p1);
课程设计任务书 2010—2011 学年第二学期 — 学年第二专业: 信息管理与信息系统 课程设计名称: 设计题目: 学号: 数据结构课程设计 双向链表的建立插入删除算法的...
C语言 双向链表的建立 删除 插入_计算机软件及应用_IT/计算机_专业资料。C语言 双向链表的建立 删除 插入双向链表建立 struct dnode { int data; struct dnode ...
建立双向链表 实现对双向链表的插入 删除操作1_工学_高等教育_教育专区。#...= NULL ) //当 head 的指向不为 NULL 时, 就是链表中还存 在节点 { ...
加入阅读会员!获取下载券 建立双向链表 实现对双向链表的插入 删除操作 隐藏>> #include<iostream> using std::cout; using std::endl; template<typename T>...
摘要 设计一个个人电话本,该电话本是基于双链表的具体功能实现,双链表的主要功能是查找、删除和 插入。其具体的实现过程:依次是建立空指针、构成双向链表、增加结点...
摘要: 设计一个个人电话本,该电话本是基于双链表的具体功能实现,双链表的主要功 能是查找、删除和插入。其具体的实现过程:依次是建立空指针、构成双向链表、 增加...
关键词:双链表 1/2 相关文档推荐 建立双向链表 实现对双向链... 4页 2... 双链表的建立插入删除打印操作双链表的建立插入删除打印操作隐藏>> #include<...
双向链表的建立、查找、插入、删除[1]——C语言双向链表的建立、查找、插入、删除[1]——C语言隐藏>> /*双链表的操作:查询、删除、显示、插入。 *双向链表...
简单实现 双向链表的插入删除简单实现 双向链表的插入删除隐藏>> #include "...()// 实现结构体 创建链表 { struct long_int *head; head=(struct long_...
双向链表插入删除基本操作演示_IT/计算机_专业资料。数据结构,教辅... 双向链表基本操作 2页 1下载券 链表插入和删除 2页 免费 双向循环链表的建立...
热门文档