打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
链表(数据结构)

#include "malloc.h"
#include "stdio.h"
#define  NULL  0
struct LO
{int  data;
 struct LO *next;
};
struct LO *creat(void)
{struct LO  La,*head,*p1,*p2;
 int i,j,n=0;i=0;
 p1=p2=malloc(sizeof(struct LO));
 p1->data=0;
 p1->next=NULL; printf("please input a number\n");   head=P1;
 while(i<m)
 {p2=malloc(sizeof(stuct LO));
  scanf("%d",&p1->data);
  p2->next=NULL;  p1->next=p2;p1=p1->next;
 }
 return(head);
}
void insert(struct LO*head,int i,int e)
{struct LO *p0,*p1,*p2;
 int j=0;
 p0=malloc(sizeof(struct LO)); p1=head;
 if(head==NULL){head=p0;p0->next=NULL;}
 eles{while(p1->next!=NULL&&j<=i-1)
      {p1=p1->next,++j;}
 p0->data=e;p0->next=p1->naxt;p1->next=p0;}
}
void del(structLO*head,int i)
{struct LO *p1,*p2;  int j
 p1=head;j=0;
 while(p1->naxt&&j<i-1)
{p1=p1->next;j++;
 }
q=p1->next;p->next=q=>next;
e=q->data;free(q);printf("%d",e);
}
main()
{stuct LO LA,LB,*p;
inti.j.m,e;
m=structLO*creat(void);
putchar();
printf("please inpput the number");
scanf("%d%d",&i,&e);
strict LO*insert(stuct LO *m,int i,int e)
printf("please input a number");
scanf("%d",&j);
if(i!=5)printf("error\nplease input a  rigth number");
else void del(struct LO *head,int i);
}

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
剑指offer之用链表实现栈(带头节点)
单向链表、双向链表,栈,队列的C语言的实现方法
c语言
049.基数排序
7-2 两个有序链表序列的合并
用指针实现高低位倒序,疯了吧
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服