Data Structure & Algorithm
sequential test
Rogue
2022. 10. 19. 00:33
반응형
#include <stdio.h>
typedef struct _node
{
int data;
struct _node* next;
}Node;
typedef struct _list
{
Node* head;
Node* curr;
Node* before;
int number;
}List;
void Init(List* copy)
{
copy->head = (Node*)malloc(sizeof(Node));
copy->head->next = NULL;
copy->number = 0;
}
void Insert(List* copy, int data)
{
Node* newNode = (Node*)malloc(sizeof(Node));
newNode->data = data;
newNode->next = copy->head->next;
copy->head->next = newNode;
(copy->number)++;
}
int Count(List* copy)
{
return copy->number;
}
int main(void)
{
List list;
int data;
Init(&list);
Insert(&list, 10);
Insert(&list, 20);
Insert(&list, 30);
printf("Current Number of Data : %d\n", Count(&list));
return 0;
}
반응형