#include<stdio.h>
#include<stdlib.h>
typedef int element;
typedef struct list{
element data;
struct list * link;
} list;
void create_node(list *head_node , list * pre_node, list * new_node, element data){
new_node = (list *)malloc(sizeof(list));
if(new_node == NULL){
error("error");
}
new_node->data = data;
new_node->link = NULL;
if(head_node == NULL){
pre_node->data = data;
pre_node->link = head_node;
head_node=pre_node;
}
else{
new_node->data = data;
new_node->link = head_node;
head_node=new_node;
}
}
list *search(list *head, int val){
list *p = NULL;
p = head;
while(p != NULL){
if( p->data == val)
return p;
p = p-> link;
}
return p;
}
void display(list * head){
list *p = head;
while(p != NULL){
printf("%d->",p->data);
p = p -> link;
}
}
int main(void){
list *list1=NULL;
create_node(list1,NULL,list1,10);
/*create_node(list1,search(list,10),list1,20);
create_node(list1,search(list,10),list1,30);*/
display(list1);
return 0;
}
'이전것 > Algorithm' 카테고리의 다른 글
원형 연결 리스트 (0) | 2014.04.14 |
---|---|
Orwell Dev C++ (0) | 2014.04.10 |
단순 연결리스트 (0) | 2014.04.09 |
도전 프로그래밍 2-3 (0) | 2014.04.09 |
정적리스트 is_in_list (0) | 2014.04.07 |