随笔分类 -  C语言链表的增删改查

#include #include typedef struct LNode{ int data; struct LNode *next; }; LNode *Init_LNode(){ LNode *head; head=(LNode *)malloc(sizeof(LNode)); head->next=NULL; return (head); } LNode *Create_LNode(LNode *head){//尾插创建 LNode *newp,*p; int a; p=head; printf("请输入链表数据a:\n"); scanf("%d",&a); while(a!=-1){ newp=(LNode *)malloc(sizeof(LNode)); newp->data=a; newp->next=NULL; p->next=newp; p=newp; scanf("%d",&a); } return head; } LNode *Insert_LNode(LNode *head){//头插 LNode *newp,*q; int a; printf("请输入要插入的数据:"); scanf("%d",&a); while(a!=-1){ newp=(LNode *)malloc(sizeof(LNode)); newp->data=a; newp->next=head->next;//头插 head->next=newp; scanf("%d",&a); } return head; } LNode *delete_byValue(LNode *head){//按值删除 LNode *p,*q; int e; printf("输入要删除的数:\n"); scanf("%d",&e); q=head; p=head->next; while(p!=NULL&&p->data!=e){ q=p; p=p->next; } if(p==NULL){ printf("元
摘要:#include<stdio.h> #include<malloc.h> typedef struct LNode { int data; struct LNode *next; }; LNode *Init_LNode() { LNode *head; head=(LNode *)malloc(s 阅读全文
posted @ 2019-07-30 00:39 收购阿里巴巴 阅读(580) 评论(0) 推荐(0)