Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ Q/A
[3137] 소스에 빈 함수를 짜야 되는데 모르겠어요.... 링크드 리스트
궁금한이 [] 1446 읽음    2003-12-14 18:02
/*------------------------------------------------------------------------------------------
  
   다음은 double linked-list를 구현한 프로그램의 일부분이다.
   함수의 본체를 구현 하시오.
-------------------------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>

/* 노드 자료 구조 정의 */
struct node {
    int          item;  /* 값 */
    struct node* prev;  /* 이전 노드에 대한 포인터 */
    struct node* next;  /* 다음 노드에 대한 포인터 */
};

/* 함수 prototype 선언 */
struct node* insert(struct node** head, int v);
void delete(struct node** head, int v);
void print_list(struct node* head);
void clear_list(struct node* head);

int main()
{
    int data[5] = {4, 2, 5, 7, 10 };

    struct node* head = NULL;

    insert(&head, data[0]);
    printf("insert %d\n", data[0]);
    print_list(head);
    printf("------------------------\n");

    insert(&head, data[1]);
    printf("insert %d\n", data[1]);
    print_list(head);
    printf("------------------------\n");

    insert(&head, data[2]);
    printf("insert %d\n", data[2]);
    print_list(head);
    printf("------------------------\n");

    delete(&head, data[0]);
    printf("delete %d\n", data[0]);
    print_list(head);
    printf("------------------------\n");
   
    delete(&head, data[1]);
    printf("delete %d\n", data[1]);
    print_list(head);
    printf("------------------------\n");
   
    delete(&head, data[2]);
    printf("delete %d\n", data[2]);
    print_list(head);
    printf("------------------------\n");

    clear_list(head);

    return 0;
}

/*-----------------------------------------------------------------------------------------------
   insert(head, v) : heard가 가리키는 리스트에 v를 오름차순으로 정렬하여 삽입한다.
   head            : 더블 링크르 리스트의 header 포인터
   v               : 삽입할 값

   return value    : 새로 생성된 노드에 대한 포인터
------------------------------------------------------------------------------------------------*/
struct node* insert(struct node** head, int v)
{

}

/*-----------------------------------------------------------------------------------------------
   delete(head, v) : head가 가리키는 리스트에서 v를 삭제한다.(v는 반드시 존재한다고 가정한다.)
   head            : 더블 링크르 리스트의 header 포인터
   v               : 리스트에서 삭제할 값
------------------------------------------------------------------------------------------------*/
void delete(struct node** head, int v)
{
}


/*-----------------------------------------------------------------------------------------------
   print_list(head) : 헤드가 가리키는 리스트의 내용을 출력한다.
   head             : 더블 링크르 리스트의 header 포인터
------------------------------------------------------------------------------------------------*/
void print_list(struct node* head)
{
}


/*-----------------------------------------------------------------------------------------------
   clear_list(head) : 헤드가 가리키는 리스트의 모든 노드를 삭제한다.
   head             : 더블 링크르 리스트의 header 포인터
------------------------------------------------------------------------------------------------*/
void clear_list(struct node* head)
{
}

+ -

관련 글 리스트
3137 소스에 빈 함수를 짜야 되는데 모르겠어요.... 링크드 리스트 궁금한이 1446 2003/12/14
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.