#include<stdio.h>
#include<stdlib.h>
typedef struct _node{
int value;
struct _node*next;
}Node;
typedef struct _list{
Node*head;
}List;
void add(ListPList,int number);
void print(ListPList);
int main( int argc,char *argv[])
{
List list;
int number=0;
list.head=NULL;
do{
scanf("%d",&number);
if(number!=-1){
add(&list,number);
}
while (number!=-1);
print(&list);
return 0;
}
void add(ListPList,int number)
{
Nodep=(Node*)malloc(sizeof(Node));
p->value=number;
p->next=NULL;
Node*list=PList->head;
if (last){
while (list->next){
list=list->next;
}
list->next=p;
}else {
PList->head=p;
}
}
void print(ListPList)
{
int number;
scanf("%d",&number);
Nodep;
int isFound=0;
for(p=list.head;p;p=p->next){
if(p->value==number){
printf("找到了\n");
isFound=1;
break;
}
if(isFound){
printf("未找到\n");
}
}
Node*q;
for(q=NULL,p->list.head;p;q=p,p=p->next){
if(p->value==number){
if(q){
q->next=p->next;
break;
}else {
list.head=p->next;
}
free(p);
break;
}
}
for(p=head;p;p=q){
q=p->next;
free(p);
}
}