BLOG main image
분류 전체보기 (32)
Blah Blah (2)
Issue (0)
Movie (0)
Utility (3)
Phone (6)
NoteBook (1)
Information Technology (5)
Good Site (3)
Etc (2)
학교 과제 (9)
156,399 Visitors up to today!
Today 23 hit, Yesterday 42 hit
daisy rss
tistory 티스토리 가입하기!
'자료구조&알고리즘'에 해당되는 글 1건
2008/03/20 14:52
[Etc]

#include<stdio.h>
#include<stdlib.h>
/*1.연결리스트의 자료형*/
typedef struct NODE{
 int key;
 struct NODE *next;

}node;

node *head, *tail;

/*2. 연결리스트의 초기화 */
void init_list(void){
 head = (node*)malloc(sizeof(node));
 tail = (node*)malloc(sizeof(node));

 head->next = tail;
 tail->next = tail;


}

/*순차적으로 입력*/
node ordered_list(int k){
 node *p;
 node *s;
 node *n_new;
 
 p = head;
 s = p->next;
 while(s->key <=k && s!=tail){
  p= p->next;
  s= p->next;
 }
 n_new=(node*)malloc(sizeof(node));
 n_new->key = k;
 n_new->next = s;
 p->next = n_new;

 return *n_new;
}

void print_list(node *t){

 printf("\n");
 while(t!=tail){
  printf(" %d",t->key);
  t=t->next;
 }
}

void main(){
 init_list();
 ordered_list(10);
 ordered_list(5);
 ordered_list(2);
 print_list(head->next);
}

'Etc' 카테고리의 다른 글

과제  (0) 2008/03/20
트랜스포머 바탕화면 1600x1200  (0) 2007/08/12
Trackback Address :: http://lunics.net/trackback/41
Name
Password
Homepage
Secret
prev"" #1 next