728x90
반응형
#include <stdio.h>
typedef struct _node
{
int data;
struct _node* next;
}Node;
typedef struct _list
{
Node* head;
Node* curr;
Node* back;
int number;
}List;
void Init(List* copy)
{
Node* head = (Node*)malloc(sizeof(Node));
head->next = NULL;
copy->number = 0;
}
void Insert(List* copy, int data)
{
Node* newNode = (Node*)malloc(sizeof(Node));
newNode->data = data;
newNode->next = NULL;
if (copy->head->next == NULL)
copy->head->next = newNode;
else
copy->head->next = NULL;
copy->number++;
}
void Num(List* copy)
{
printf("%d", copy->number);
}
int main(void)
{
List list;
Init(&list);
Insert(&list, 10);
Insert(&list, 20);
Insert(&list, 30);
Num(&list);
return 0;
}
728x90
반응형
'Data Structure & Algorithm' 카테고리의 다른 글
Circular Linked List(+ division) (0) | 2022.10.20 |
---|---|
Sequential Dummynode (0) | 2022.10.19 |
Maze (0) | 2022.10.19 |
other bill (0) | 2022.10.19 |
Basic (0) | 2022.10.19 |