return 0;
}
struct st * zeng(struct st * head)
{
struct st * p,* q;
int j=0,n;
printf("输入要插入的位置:/n");
scanf("%d",&n);
int i;
i=size(head);
if(0<n&&n<i+1)
{
p=head;
while(p&&j<n-1){
p=p->next ;
j++;
}
printf("输入要插入的数:/n");
q=(struct st *)malloc(sizeof(st));
scanf("%d",&q->num);
q->next =p->next ;
p->next =q;
p=p->next ;
p=head;
p=p->next ;
while(p){
printf("%d ",p->num);
p=p->next ;
}
printf("/n");
}
else{
printf("输入有误/n");
}
return 0;
}
struct st * create()
{
struct st * head=NULL;
head=(struct st * )malloc(sizeof(st));
return head;
}
struct st * insert(struct st * head)
{
printf("请输入号码(以-1结束):/n");
struct st *p=NULL,*q=NULL;
int i;
q=head;
p=(struct st *)malloc(sizeof(st));
while(scanf("%d",&p->num)!=EOF)
{
if(p->num==-1)
break;
q->next=p;
q=p;
p=(struct st *)malloc(sizeof(st));
}q->next=NULL;
return 0;
}
struct st * search(struct st *head)
{
struct st *p,*q,*r;
p=head->next;
while(p){
q=p;
while(q->next){
if(q->next->num==p->num)
{
r=q->next;
q->next =r->next ;
free(r);
}
else{
q=q->next ;
}
}p=p->next ;
}
return 0;
}
int size(struct st * head)
{
int i=0;
struct st * p;
p=head;
p=p->next ;
while(p)
{
i++;
p=p->next ;
}
return i;
}