自己写了一个链表的小程序,好多错,帮我改改
#include <iostream>using namespace std;
struct node
{
int data;
node *next;
};
int init()
{
node * head;
head=NULL;
}
int insert(node a)
{
while(p->data!=0)
{
p=new node;
cout>>"please enter some node:";cin>>a;
head=p;
p->data=a.data;
p=p->next;
}
return head;
}
void find(node b)
{
cout<<"please enter b:"<<endl;cin>>b;
while(p!=NULL)
{
if(b.data==p->data)
{
cout<<"have find node b"<<endl;
break;
}
else
p=p->next;
}
}
void main()
{
node *p;
init();
insert(a);
find(b);
}