#include <stdio.h>
#include<stdlib.h>
typedef struct _node{
int value;
struct _node *next;
}Node;
typedef struct _list{
Node* head;
}List;
void add(List* pList,int number);
void print(List *pList);
int main () {
List list;
list.head = NULL;
int number;
do{
scanf("%d",&number);
if(number != -1){
add(&list, number);
}
}while(number != -1);
print(&list);
scanf("input a number:%d",&number);
Node *p;
int isFound = 0;
for(p = list.head;p;p = p->next){
if(p->value == number){
printf("Find it!\n");
isFound=1;
break;
}
}
if(!isFound){
printf("NOT Find it!\n");
}
return 0;
}
void add(List* pList,int number){
Node *p = (Node*)malloc(sizeof(Node));
p->value = number;
p->next = NULL;
Node *last = pList->head;
if(last != NULL){
while(last->next){
last = last->next;
}
last->next = p;
printf("add:%i\n",p->value);
}else{
pList->head = p;
}
}
void print(List *pList){
Node *p;
for(p = pList->head;p;p=p->next){
printf("%d\t",p->value);
}
printf("\n");
}