数据结构(C语言)线性表的创建、插入、删除等操作
#include<stdio.h>
#include<stdlib.h>
#define TRUE 1;
#define FALSE 0;
#define OK 1;
#define ERROR 0;
#define OVERFLOW -2;
typedef int Status;
typedef int ElemType;
typedef struct LNode {
ElemType data;
struct LNode *next;
}LNode,*LinkList;
void CreateList(LinkList &L,int n)
{
L = (LinkList)malloc(sizeof(LNode));
L->next = NULL;
for (int i= n; i>0; i--)
{
LNode *p = (LinkList)malloc(sizeof(LNode));
scanf_s("%d",&p->data);
p->next = L->next;
L->next = p;
}
}
void OutputList(LinkList L)
{
LNode *p = L->next;
while (p)
{
printf("%d\n",p->data);
p = p->next;
}
}