//http://codeup.cn/showsource.php?id=1430493
#include<cstdlib>//malloc func
#include<cstdio>//stdio func
#include<cstring>//strcmp func
#define OK 1
#define ERROR 0
typedef int Status;//function type
typedef int ElemType;//LNode data type
typedef struct LNode{
ElemType data;//data element definition
struct LNode *next;//next node address definition
}LNode, *LinkList;//node type & list type definition
Status GetElem_L(LinkList &L,int i, ElemType &e){
//L is head node
LinkList p;
p=L->next;
int j=1;//p is the 1st node(next to L), j is a counter
while (p&&j<i){//find the node i(L is node 0)
p=p->next;
++j;
}
if (!p||j>i)//node i is not exist
return ERROR;
e=p->data;//e is data of node i
return OK;
}
Status ListInsert_L(LinkList &L, int i,ElemType e){
//insert new data before node i