C语言单链表实现填空最好是尾插法,不知道该怎么填,求助!
开心小学徒 2017-10-23 07:45:48 #include <stdio.h>
#include<stdlib.h>
typedef struct LNode{
int data;
struct LNode *next;
}LNode;
void create(LNode *L); //用头插法或尾插法创建单链表
void display(LNode *L); //显示单链表的数据
void Insert(LNode *L,int i,int x); //在单链表第i个位置插入值为x的元素
void Delete(LNode *L,int i); //删除单链表中第i个元素
int main(int argc, char *argv[])
{
LNode *L;
int i,x;
L=(LNode *)malloc(sizeof(LNode));
L->next=NULL;
create(L);
display(L);
printf("单链表的插入,请输入插入位置:");
scanf("%d",&i);
printf("请输入插入的值");
scanf("%d",&x);
Insert(L,i,x);
printf("插入后的链表为:");
display(L);
printf("单链表的删除,请输入删除位置:");
scanf("%d",&i);
Delete(L,i);
printf("删除后的链表为:");
display(L);
return 0;
}
各个子函数该怎么填?求助!