c语言线性表建立10个节点,数据结构题目,建立一个10个节点的链表,然后删...-卓优商学院问答...

推荐回答

#include#includetypedefstructLNode{intdata;structLNode*next;}LNode,*Llist;LNode*creat_head;//创建一个空表voidcreat_listLNode*,int;//创建一个长度为n的线性链表voidinsert_listLNode*,int,int;//插入一个元素intdelete_listLNode*,int;//删除一个元素main{LNode*head,*p;intn;intx,i;intb;clrscr;head=creat_head;printf"n=";scanf"%d",&n;creat_listhead,n;forp=head->next;p!=NULL;{printf"%d",p->data;p=p->next;}printf"*****************************************************";printf"x=";scanf"%d",&x;printf"inserti=";scanf"%d",&i;insert_listhead,x,i;forp=head->next;p!=NULL;{printf"%d",p->data;p=p->next;}printf"*********************************************************";printf"deletei=";scanf"%d",&i;b=delete_listhead,i;forp=head->next;p!=NULL;{printf"%d",p->data;p=p->next;}printf"deleteb=%d",b;getch;}//创建一个空链表LNode*creat_head{LNode*p;p=LlistmallocsizeofLNode;p->next=NULL;returnp;}//创建一个长度为n的线性链表voidcreat_listLNode*head,intn{LNode*p,*q;inti;p=head;fori=1;idata;q->next=NULL;p->next=q;p=q;}}//插入一个元素voidinsert_listLNode*head,intx,inti{intj=0;LNode*p,*s;p=head;whilep!=NULL&&jnext;j++;}ifp==NULLexit0;s=LlistmallocsizeofLNode;s->data=x;s->next=p->next;p->next=s;}//删除一个元素intdelete_listLNode*head,inti{LNode*p,*q;intj=0;intx;p=head;whilep!=NULL&&jnext;j++;}ifp==NULLexit0;q=p->next;p->next=q->next;x=q->data;freeq;returnx;}大哥这可是我一个字符一个字符的敲进去的啊~~~!!!我是学软件工程的,这是线性表的链式存储结构.。

赵颖莹2019-11-05 20:36:47

卓优商学院提示您:回答为网友贡献,仅供参考。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值