#include <stdio.h>
#include<malloc.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define ERROR 0
#define OK 1
#define INFEASIBLE -1
#define OVERFLOW -2
#define MAXSIZE 100
typedef int Status;
typedef int ElemType;
typedef struct LNode{
ElemType data;
struct LNode *next;
}LNode, *LinkList;
Status InitList(LinkList &L)
{
L=(LNode*)malloc(sizeof(LNode));
if (!L)
exit(OVERFLOW);L->next=NULL;
return OK;
}
Status ListInsert_L(LinkList &L, int i, ElemType e)
{
LNode *p,*s;int j;
p=L;j=0;
while(p&&j<i-1){p=p->next;++j;}
if (!p||j>i-1) return ERROR;
s=(LinkList)malloc(sizeof(LNode));
s->data=e;s->next=p->next;
p->next=s;
return OK;
}
int main()
{
LinkList L;
int i;
InitList(L);
for (i=1;i<=10;i++)
ListInsert_L(L,i,i);
LNode *p;
p=L->next;
while(p!=NULL)
{printf("%5d",p->data);p=p->next;}
return 0;
}