头文件:
typedef int DataType;
typedef unsigned int size_t;
#define NULL 0
typedef struct Node
{
DataType _data;
struct Node* _pNext;
}Node, *PNode;
源文件:
#include "LinkList.h"
#include <stdlib.h>
#include <stdio.h>
// 在单链表的尾部插入一个节点
void PushBack(PNode* pHead, DataType data)
{
PNode pNewNode = NULL;
PNode pCurNode = NULL;
pNewNode = BuyNode(data);
if(pNewNode == NULL)
return;
if(*pHead == NULL)
{
*pHead = pNewNode;
}
else
{
pCurNode = *pHead;
while(pCurNode->_pNext)
{
pCurNode = pCurNode->_pNext;
}
pCurNode->_pNext = pNewNode;
}
}
// 构建一个新节点
Node* BuyNode(DataType data)
{
PNode node = (PNode)malloc(sizeof(Node));
if(node == NULL)
re