#include<stdio.h>
#include<stdlib.h>
#define MAX 300000
#define DEBUG 0
typedef struct{
int data;
struct node * link;
}node;
node * get_node(){
node *tmp =(node *)malloc(sizeof(node));
tmp->data = 0;
tmp->link = NULL;
return tmp;
}
void pl(node *start){
node *tmp;
printf("%d n",start->data);
if(start->link==NULL)return ;
tmp = start->link;
while(1){
printf("%d n",tmp->data);
if(tmp->link == NULL)break;
tmp = tmp->link;
}
}
void insert(node **start,int toFind,int data){
node *tmp,*toInsert ;
int flag = 1;
if(*start==NULL){ //업을때는 검색없이 삽입
*start = get_node();
(*start)->data = data;
return;
}
tmp = *start;
while(1){
if(toFind == tmp->data){
toInsert = get_node();
toInsert->link = tmp->link;
tmp->link = toInsert;
toInsert->data = data;
return;
}
if(tmp->link ==NULL)break;
tmp = tmp->link;
}
toInsert = get_node();
toInsert->data = data;
tmp->link = toInsert;
}
int main(int* argc,char* argv[]){
node *start=NULL;
insert(&start,343, 3); //첫값
insert(&start,3 , 34); //3뒤에 붙는 값.
insert(&start,111, 11); //못찾아서 맨뒤에 붙는 값.
pl(start);
}


