线性链表(救命用的)!!!(100分)

  • 主题发起人 主题发起人 无人的世界
  • 开始时间 开始时间

无人的世界

Unregistered / Unconfirmed
GUEST, unregistred user!
#include<stdio.h>
#include<malloc.h>
#include<string.h>
#define NULL 0
typedef struct ElemType
{char *s;
int age;
int number;
}ElemType;
typedef struct LNode
{ElemType data;
struct LNode *next;
}LNode,*LinkList;
LListInit(LinkList &amp;L)
{L=(LinkList)malloc(sizeof(LNode));
if(!L) return 0;
L->next=NULL;
return 1;
}
void LListInsert(LinkList &amp;L,int i,LNode * e)
{LNode *p;

p=L->next;
while(p)
p=p->next;
p->next->data=e->data;
p->next->next=e->next;
}
void main()
{ LinkList L;int i=1;
LNode *e;LListInit(L);
e=(LNode*)malloc(sizeof(LNode));
e->data.number=2;
e->data.age=5;
strcpy(e->data.s,"he");
e->next=NULL;

LListInsert(L,i,e);


}
 
void LListInsert(LinkList &amp;L,int i,LNode * e)
{ LNode *p;
p=L;
while(p->next)
p=p->next;
p->next=e;
}
 
还是不可以啊
 
后退
顶部