双向链表删除问题
来源:互联网 发布:力高答题软件 编辑:程序博客网 时间:2024/05/17 18:15
关于自己为什么总是犯很脑残的错误。。。吃点脑残片估计就好了
上代码,双向链表删除问题:
#include <stdio.h>#include <stdlib.h>typedef struct DLNode{ int data; DLNode *prior; DLNode *next;}*DList,DLNode;void Creat(DList &L,int n){//这次要采用尾插法来创建双向链表 L=(DList)malloc(sizeof(struct DLNode)); L->next=NULL; DList s,t; t=L;//t将会代表L进行一系列的活动 for(int i=1;i<=n;i++){ s=(DList)malloc(sizeof(struct DLNode)); scanf("%d",&s->data); s->prior=t; t->next=s; t=s; } t->next =NULL;}void Delete(DList &L,int i,int &e){//删除第i个节点,并返回这个节点的数值 DList p; p=L; int j=0; while (p&&j<i){ j++; p=p->next; } if(j!=i){ printf("这种点不存在!"); } if(p->next==NULL){ p->prior->next=NULL; } else{ e=p->data ; p->prior->next =p->next; p->next->prior =p->prior; }}void Print(DList L3){ L3=L3->next; while(L3){ printf("%d",L3->data); L3=L3->next; }}int main(){ DList L; int n,i,e; scanf("%d,%d,%d",&n,&i,&e); Creat(L,n); Print(L); Delete(L,i,e); Print(L); return 0;}
阅读全文
0 0
- 双向链表删除问题
- list_head双向链表的删除问题
- 嵌入式 双向链表节点的删除的问题
- 约瑟夫问题--双向循环链表的创建与删除
- 双向链表插入删除
- 双向链表删除节点
- 双向链表基本操作:删除、插入、双向输出
- C语言实现双向链表删除、插入、双向输出
- 双向循环链表的删除
- 双向链表元素的删除
- 双向链表的创建和删除
- 双向链表元素的删除
- 两个双向链表删除相同元素
- 双向链表的创建删除
- 双向链表实现 插入删除
- 双向链表建立、插入和删除
- 双向循环链表的插入删除
- 双向链表插入、删除操作
- js中this及碰触浮现div实例
- Socket.IO连接服务
- 【算法】常用排序算法时间空间复杂度
- MySQL最大连接数设置
- 概率图模型9:贝叶斯网络
- 双向链表删除问题
- redirect
- LeetCode-258. Add Digits
- ThreadPoolExecutor使用介绍
- 深度学习-微调
- 14、权限管理之文件特殊权限SUID、SGID、SBIT
- ueditor插件在ie上传图片出现下载JSON文件的解决
- cocos2d-x 3.3连接Xcode9编译时报错:call to unavailable function system not available on ios
- Android 中性能优化工具之Hierarchy Viewer使用总结