70,011
社区成员




typedef struct LNode{
ElemType date;
struct LNode *next;
}*LinkList;
//Initial LinkList
void InitL(LinkList &L){
L = (LinkList)malloc(sizeof(LNode));//we just need a RAM directory to told us where the LinkList is.
L->next = NULL;
}
//Create LinkList
void CreateL(LinkList &L){
int len; //Firstly,we need to known the length of the LinkList.
printf("Please input L length:");
scanf("%d", &len);
for(int i = 0 ; i < len; i++){
LinkList p = (LinkList)malloc(sizeof(LNode)); //or LinkList p = new LNode(c++)
if(!p)
printf("Error\n");
printf("Please input LinkList number:");
scanf("%d", &p->date);
//tail insert
L->next = p;
L = p;
}
}