/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*
#include <stdio.h>
int get_num(void);
int main(void)
{
int result;
result = get_num();
printf("반환값 : %d\n",result);
return 0;
}
int get_num(void)
{
int num;
printf("양수 입력 : ");
scanf("%d",&num);
return num;
}
*/
/*
#include <stdio.h>
void print_char(char ch, int count);
int main(void)
{
print_char('@',5);
return 0;
}
void print_char(char ch, int count)
{
int i;
for(i = 0; i < count; i++)
{
printf("%c",ch);
}
return;
}
*/
/*
#include <stdio.h>
void print_line(void);
int main(void)
{
print_line();
printf("학번 이름 전공 학점\n");
print_line();
return 0;
}
void print_line(void)
{
int i;
for(i = 0; i < 50; i++)
{
printf("-");
}
printf("\n");
}
*/
/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*
#include <stdio.h>
int max3(int a, int b, int c)
{
int max;
if(a >= b)
{
if(a>=c)
{
max = a;
}
else
{
max = c;
}
}
else
{
if(b>=c)
{
max = b;
}
else
{
max = c;
}
}
}
int main()
{
int a, b, c, max;
printf("3개의 수입력:");
scanf("%d,%d,%d",&a,&b,&c);
max=max3(a,b,c);
printf("최대수=%d\n",max);
return 0;
}
*/
/*
#include <stdio.h>
void print_star(int m, int n)
{
for(int i = m; i <= n; i++)
{
for(int j = 1; j <= i; j++)
{
printf("*");
}
printf("\n");
}
}
int main()
{
int m, n, sum = 0;
printf("m,n=");
scanf("%d,%d",&m,&n);
print_star(m,n);
return 0;
}
*/
/*
struct node
{
int num;
struct node*link;
};
int main()
{
struct node a, b;
a.num = 0;
a.link = &b;
b.num = 1;
printf("%d",a.link -> num);
return 0;
}
*//*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct listNode
{
char data[10];
struct listNode* link;
} listNode;
typedef struct
{
listNode* head;
}linkedlist_h;
linkedlist_h*createLinkedList_h(void);
void freeLinkedList_h(linkedlist_h*);
void addLastNode(linkedlist_h*,char*);
void reverse(linkedlist_h*);
void deleteLastNode(linkedlist_h*);
void printList(linkedlist_h*);
linkedlist_h* createLinkedList_h(void)
{
linkedlist_h* L;
L = (linkedlist_h*)malloc(sizeof(linkedlist_h));
L->head=NULL;
return L;
}
void addLastNode(linkedlist_h* L,char* x)
{
listNode* newNode;
listNode* p;
newNode = (listNode*)malloc(sizeof(listNode));
strcpy(newNode->data,x);
newNode ->link=NULL;
if(L->head==NULL)
{
L->head = newNode;
return;
}
p = L->head;
while(p->link != NULL)
{
p = p ->link;
}
p -> link = newNode;
}
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct DNode
{
struct DNode *llink;
char data[5];
struct DNode *rlink;
} DNode;
typedef struct Dlinked_h
{
DNode* head;
} Dlinked_h;
Dlinked_h* createDList_h(void)
{
Dlinked_h* L;
L = (Dlinked_h*)malloc(sizeof(Dlinked_h));
L->head = NULL;
return L;
}
void addMiddleNode(Dlinked_h* L, DNode* pre,char* x)
{
DNode* newNode;
DNode* p;
newNode = (DNode*)malloc(sizeof(DNode));
strcpy(newNode->data,x);
newNode->rlink= pre->rlink;
pre->rlink= newNode;
newNode->llink=newNode->rlink->llink;
newNode->rlink->llink=newNode;
}
void deleteNode(Dlinked_h* L, DNode* old)
{
old->llink->rlink = old->rlink;
old->rlink->llink=old->llink;
}
int LInsert(Dlinked_h* L,char* data)
{
DNode * newNode = (DNode*)malloc(sizeof(DNode));
strcpy(newNode->data, data);
L -> head = NULL;
newNode->rlink= L->head;
newNode ->llink = NULL;
L -> head = newNode;
}
void line(void)
{
for(int i = 0; i < 100; i++)
{
printf("-");
}
printf("\n");
}
void view(Dlinked_h* L)
{
DNode* p;
p = L -> head;
line();
while( p -> rlink != NULL)
{
p = p ->rlink;
printf("%s ",p->data);
}
line();
}
int main()
{
Dlinked_h* L ;
L->head = NULL;
// LInsert(L,"abcd");
view(L);
// 노드를 추가하고 삭제하는 코드 만들기
// 과정 프린트하기
}