데이터 구조 -- 직렬 - 체인 식 저장
4029 단어 데이터 구조
#include <stdio.h>
struct node{
char ch;
struct node *next;
};
/* 1. */
void init(struct Node **h)
{
*h = (struct node *)mallov(sizeof(struct node));
if(*h == NULL)
{
printf(" ...
");
system("pause");
}
(*h)->next = NULL:
return;
}
/* 2. x */
void append(struct node *p, int x)
{
struct node *s;
s = (struct node *)malloc(sizeof(struct node));
if(*h == NULL)
{
printf(" ...
");
system("pause");
}
s->ch = x;
while(p->next != NULL)
{
p = p->next;
}
p->next = s;
return;
}
/* 3. */
void display(struct node *p)
{
while(p->next != NULL)
{
printf("%c",p->next->ch);
p=p->next;
}
printf(" ");
return;
}