【单链表的打印】:
//单链表的打印
void print(node *head)
{
node *p;
int index = 0;
if(head->next == NULL) //链表为空
{
cout << "Link is empty"<<endl;
return;
}
p = head->next;
while(p != NULL)
{
cout<<"The "<<++index << "node is :"<< p->data <<endl; //打印元素
p = p->next;
}
}