单链表
//初始化
struct ListNode
{
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
ListNode *head = new ListNode(-1);//建立头节点
//头插法插入元素
void headAdd(int x){
if(head -> val == -1) head -> val = x;//空链表
ListNode *node = new ListNode(x);
node -> next = head;
head= node;
}
//遍历
for(ListNode *p = head; p; p = p -> next){
}