강좌 & 팁
/* 1 -> 2 -> 3-> 4-> 5- > NULL
5 -> 4 -> 3 -> 2-> 1 -> NULL 을 출력하는 소스*/
#include"node.h"
#include<stdio.h>
int main()
{
NODE array[5];
NODE *head;
printf("-----------------------------\n");
array[0].iNum = 5;
array[0].next = &array[1];
array[0].prev = NULL;
array[1].iNum = 1;
array[1].next = &array[2];
array[1].prev = &array[0];
array[2].iNum = 4;
array[2].next = &array[3];
array[2].prev = &array[1];
array[3].iNum = 2;
array[3].next = &array[4];
array[3].prev = &array[2];
array[4].iNum = 3;
array[4].next = NULL;
array[4].prev = &array[3];
head = &array[0];
while(head!=NULL)
{
printf("%d -> ", head -> iNum);
head = head -> next;
}
printf("NULL\n");
printf("-----------------------------\n");
head = &array[4];
while(head!=NULL)
{
printf("%d -> ", head -> iNum);
head = head -> prev;
}
printf("NULL\n");
printf("-----------------------------\n");
return 0;
}