单链表的建立插入删除查找哪位大神帮忙看下这个程序哪里错了
#include<stdio.h>#include<iostream.h>
#include<stdlib.h>
int n;
typedef struct lnode{
int data;
struct lnode * next;
}lnode, * linklist;
linklist p;
void createlist(linklist L)
{cout<<"plese enter you hope data'number:"<<endl;
cin>>n;
int i;
L=(linklist)malloc(sizeof(lnode));
L->next=NULL;
cout<<"please enter your data:"<<"\f";
for(i=n;i>0;--i)
{p=(linklist)malloc(sizeof(lnode));
cin>>p->data;
p->next=L->next;
L->next=p;
}
cout<<"your linklist is:"<<"\f";
for(i=n;i>0;--i)
{cout<<p->data<<"\f";
p=p->next;
}
}
void getlist(linklist L)
{int i,j;
p=L->next;
j=1;
cout<<"please enter your searching'place:"<<"\f";
cin>>i;
while(p&&j<i)
{p=p->next;
++j;
}
if(!p||j>i)
cout<<"the i don't exist";
cout<<"your searching is:"<<"\f";
cout<<p->data;
}
void listinsert(linklist L)
{int i,j,e;
linklist s;
p=L;
j=0;
cout<<"please enter want before which insert:"<<endl;
cin>>i;
cout<<"please enter inserting'number:";
cin>>e;
while(p&&j<i-1)
{p=p->next;
++j;}
if(!p||j>i-1)
cout<<"i is error"<<endl;
s=(linklist)malloc(sizeof(lnode));
s->data=e;
s->next=p->next;
p->next=s;
cout<<"now the linklist is:"<<"\f";
for(i=n=1;i>0;--i)
{cout<<p->data<<"\f";
p=p->next;}
}
void listdelete(linklist L)
{int i,j;
linklist q;
p=L;
j=0;
cout<<"enter you want delete's xuhao:"<<"\f";
cin>>i;
while(p->next&&j<i-1)
{p=p->next;
++j;
}
if(!(p->next)||j>i-1)
cout<<"i is error"<<endl;
{q=p->next;
p->next=q->next;
free(q);
cout<<"deleting finish";}
cout<<"now the linklist is:"<<"\f";
for(i=n;i>0;--i)
{cout<<p->data<<"\f";
p=p->next;
}
cout<<endl;
}
int mian()
{
linklist L1;
createlist(L1);
getlist(L1);
listinsert(L1);
listdelete(L1);
return 0;
}