본문 바로가기
반응형

자료구조4

[자료구조] 03. Stack Flood Fill 예제 (C언어) Stack 예제 중에서 Flood Fill에 대한 예제가 참 유명하다. 나중에 최적화 알고리즘을 사용하여 Application에 적용할수 있기 때문에 주요 Source 코드를 정리해 놓으면 요긴할것 같다. /*-----------------------Include-----------------------*/ #include #include #include #include /*-----------------------Define-----------------------*/ #define MAX_STACK_SIZE 100 #define TRUE 1 #define FALSE 0 #define WIDTH 7 #define HEIGHT 7 /*-----------------------Typedef---------.. 2021. 7. 10.
[자료구조] 02. Stack 구조 Basic 예제 (C언어) Stack을 이해하기 쉬운 예제입니다. 1. element.h struct _element { int key; }element; 2. stack.h #include "element.h" #define MAX_STACK_SIZE 5 struct _Stack { element items[MAX_STACK_SIZE]; int top; }Stack; 3. main.c #define _CRT_SECURE_NO_WARNINGS #include #include "stack.h" #define TRUE 1 #define FALSE 0 unsigned char uint8_t; unsigned int uint32_t ; int int32_t ; uint8_t IsEmpty(const Stack* pStack) { if(p.. 2021. 7. 9.
[자료구조] 01. List 구조 Baisc 예제 (C언어) List 구조에 대해서 Test 해볼수 있는 Basic 한 예제이다. #include #include #include #define NLEN 100 typedef struct _Fruit { char name[NLEN]; float score; struct _Fruit* next; }Fruit; void print_all(Fruit* head) { Fruit* search = head; printf("-------------------------------------\n"); printf("Head address = %x\n",(unsigned int)head); while(search != NULL) { printf("%x\t%s\t%f\t%x\n",(unsigned int)search, search-.. 2021. 7. 9.
[자료구조] 00. 자료 구조 들어가기 전, 배열구조 예제 (C언어) 자료 구조를 들어가기 전에 과일 평가 시스템을 한번 만들어 보도록 하자! 배열로 데이터를 어떻게 구성하고 늘려갈지에 대해서 생각을 해보는 좋은 예제 인것 같다. #include #include #include #include #define TSIZE 45 #define DMAX 10 typedef struct _fruit { char name[TSIZE]; float score; }fruit; void read_file(fruit fruit_list[], int* ptr_data_size) { char filename[TSIZE] = {0,}; FILE* file = NULL; int num = 0; int i = 0; printf("input filename to get data\n"); printf(.. 2021. 7. 9.
반응형