/*
#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);
void addMiddleNode(Dlinked_h* L, DNode* pre,char* x)
{
DNode* newNode;
DNode* p;
newNode = (DNode*)malloc(sizeof(DNode));
strcpy(newNode->data,x);
strcpy(newNode->rlink, pre->rlink);
strcpy(pre->rlink, newNode);
strcpy(newNode->llink,newNode->rlink->llink);
strcpy(newNode->rlink->llink,newNode);
}
void deleteNode(Dlinked_h* L, DNode* old)
{
strcpy(old->llink->rlink,old->rlink);
strcpy(old->rlink->llink,old->llink);
}
int main()
{
Dlinked_h L ;
L->head = NULL;
// 첫 노드 추가하는 함수 만들기
// 위 함수 사용해서 첫 노드 추가하기
// 노드를 추가하고 삭제하는 코드 만들기
// 과정 프린트하기
}