전체 글 썸네일형 리스트형 [DGPD][C언어] 배열을 이용한 트리(Tree) 구현해보기-1. 1 2 3 4 5 6 7 8 9 10 11 12 #include #define MAX_NODE_NUMBER 1000 #define MAX_CHILD_NUMBER 5 typedef struct { int parentNode; int childNode[MAX_CHILD_NUMBER]; }TreeNode; TreeNode treeNode[MAX_NODE_NUMBER]; cs TreeNode라는 구조체를 선언하고 이를 배열로 사용. 구조체 배열의 인덱스 자체가 자신의 값. 배열 내에는 부모 노드의 값, 자식 노드 배열 포함. 1 2 3 4 5 6 7 8 9 10 11 12 13 void initTree() { int i; int j; for (i = 0; i 더보기 [DGPD][C언어] 더블 링크드 리스트(Doubly linked list) 구현해보기. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133#include#include #define NULL (0) typedef struct ListNode{ int data; struct ListNode* prev; struct ListNode.. 더보기 [DGPD][C언어] 문자열 연결 함수 strcat 만들기. 12345678910111213141516171819202122232425262728293031#include char* myStrcat(char* destination, const char* source){ while (*destination != '\0') { destination++; } while (*source != '\0') { *destination = *source; destination++; source++; } *destination = '\0'; return destination;} int main(){ char str[80] = "these "; myStrcat(str, "strings "); myStrcat(str, "are "); myStrcat(str, "concatenated.. 더보기 [DGPD][C언어] 문자열 복사 함수 strcpy 만들기. 1234567891011121314151617181920212223242526#include char* mystrcpy(char* destination, const char* source){ while (*source != '\0') { *destination = *source; source++; destination++; } *destination = '\0'; return destination;} int main(){ char str1[] = "sample string"; char str2[40]; char str3[40]; mystrcpy(str2, str1); mystrcpy(str3, "copy successful"); printf("str1: %s\nstr2: %s\nstr3: %s\n", s.. 더보기 [DGPD][C언어] 문자열 비교 함수 strcmp 만들기. 1234567891011121314151617181920212223242526272829303132333435363738#include int myStrcmp(const char* str1, const char* str2){ while (*str1 != '\0' || *str2 != 0) { if (*str1 > * str2) { return 1; } if (*str1 더보기 이전 1 다음