继昨天终于明白了
成功截图
typedef struct LNode
{
int data;
struct LNode* next;
}LNode;
bool IsitList(LNode **Head)
{
*Head = (LNode*)malloc(sizeof(LNode));
if (!*Head)
return false;
(*Head)->next = NULL;
return true;
}
void ListInsert(LNode *L, int value)
{
LNode *p = L;
while (p->next)
p = p->next;
LNode *newLNode = (LNode*)malloc(sizeof(LNode));
newLNode->data = value;
newLNode->next = NULL;
p->next = newLNode;
}
void PrintList(LNode *L)
{
LNode *cur = L;
while (cur)
{
printf("%d->", cur->data);
cur = cur->next;
}
}
int main()
{
LNode *L=NULL;
IsitList(&L);//定义一个带表头空链表
ListInsert(L,1);
ListInsert(L, 2);
ListInsert(L, 3);
PrintList(L);//打印链表
system("pause");
return 0;
}
标签:Head,单链,cur,--,newLNode,next,数据结构,ListInsert,LNode
From: https://blog.51cto.com/u_16071993/6391098