//链表,头结点中要放置元素
#include<iostream>
using namespace std;
struct listnode
{
int data;
listnode* next;
};
listnode* createlistnode(int value)
{
listnode* pnode=new listnode;
pnode->data=value;
pnode->next=NULL;
return pnode;
}
void connectlistnode(listnode* pcurrent,listnode* pnext)
{
if(pcurrent==NULL)
{
cout<<"error"<<endl;
return;
}
pcurrent->next=pnext;
}
void printlistnode(listnode* pnode)
{
if(pnode==NULL)
cout<<"the listnode is null"<<endl;
else
cout<<pnode->data<<" ";
}
void printlist(listnode* phead)
{
listnode* pnode=phead;
if(phead==NULL)
cout<<"the list is nu
#include<iostream>
using namespace std;
struct listnode
{
int data;
listnode* next;
};
listnode* createlistnode(int value)
{
listnode* pnode=new listnode;
pnode->data=value;
pnode->next=NULL;
return pnode;
}
void connectlistnode(listnode* pcurrent,listnode* pnext)
{
if(pcurrent==NULL)
{
cout<<"error"<<endl;
return;
}
pcurrent->next=pnext;
}
void printlistnode(listnode* pnode)
{
if(pnode==NULL)
cout<<"the listnode is null"<<endl;
else
cout<<pnode->data<<" ";
}
void printlist(listnode* phead)
{
listnode* pnode=phead;
if(phead==NULL)
cout<<"the list is nu