线性表的链式存储实现(有头结点)
来源:互联网 发布:动画演示软件 编辑:程序博客网 时间:2024/05/21 09:30
//线性表的链式存储实现(有头结点)#include <stdio.h>struct node{ int element; struct node* next;};struct node* Insert(struct node* head,int i,int number){ int j=0; struct node* p; p=head; while(p&&j<i-1){ p=p->next; j++; } if(p==NULL){ printf("Error\n"); return; } struct node* t; t=(struct node*)malloc(sizeof(struct node)); t->element=number; t->next=p->next; p->next=t; return;}Delete(struct node* head,int i){ struct node* p; p=head; int location=0; while(location<i-1&&p){ p=p->next; location++; } if(location!=i-1||p->next==NULL){//元素不到i或者i位置为NULL printf("Error\n"); return; } struct node* temp=p->next; p->next=temp->next; free(temp); return;};struct node*Init(struct node* head){ head=(struct node*)malloc(sizeof(struct node)); head->next=NULL; return head;};int main(){ struct node* head; //初始化 head=Init(head); //插入 Insert(head,1,10);//插到第i个位置 //删除 Delete(head,1);//删除第i个元素 return 0;}
1 0
- 线性表的链式存储实现(有头结点)
- 链式存储线性表(有头结点)
- 线性表的链式存储实现(无头结点)(陈越数据结构)
- 线性表的链式存储结构(有头节点)
- 线性表的链式存储结构之单链表结点类的实现_Java
- 线性表的链式存储结构之单链表结点类的实现_Java
- 带头结点的线性表的链式实现
- PHP实现线性表的链式存储
- Java实现链式存储的线性表
- 线性表的链式存储和实现
- 线性表的链式存储与实现
- 线性表的链式存储和实现
- 线性表的链式存储实现c++
- 线性表的链式存储结构(无头节点)
- 线性表带头结点的单链表的链式表示和实现
- 线性表带头结点的单链表的链式表示和实现
- 线性表的基本操作实现(基于链表,有头结点)
- 链式存储结构的头指针和头结点
- 定时器中断
- logstash 各种时间转换
- Unity 的一道面试题 随机颜色
- android 动画
- java学习日记_31:面向对象之继承的概述、使用、特点和弊端
- 线性表的链式存储实现(有头结点)
- 对php四种排序的粗浅认知
- 文件上传
- 王爽汇编第二版第三章答案
- hdu 4734 F(x) 数位DP
- js--this
- Linux 中 bashrc 中的 rc 是什么意思
- 基础知识之session
- cf--E. The Values You Can Make(dp)