728x90
반응형

프로그래밍/C 38

연결 리스트 C언어 코드

2022.02.22 최초 작성 #include #include typedef struct Node{ int data; struct Node* next; } Node; Node* head = NULL; Node* tail = NULL; Node* cur = NULL; void printLinkedList(Node* head) { printf("연결리스트 출력 : "); cur = head; while (cur != NULL) { printf("%d", cur->data); cur = cur->next; if (cur != NULL) printf("->"); } puts(""); } void addNode() { while (1) { int item; printf("연결할 정수를 입력하세요. "); scan..

프로그래밍/C 2023.02.22

스택 C언어 코드

2023.02.21 최초 작성 #include #include #define MAX_STACK_SIZE 10 typedef int element; element stack[MAX_STACK_SIZE]; int top = -1; // 공백 상태 검출 함수 int is_empty() { return (top == -1); } // 포화 상태 검출 함수 int is_full() { return (top == (MAX_STACK_SIZE - 1)); } // 삽입 함수 void push(element item) { if (is_full()) { fprintf(stderr, "스택이 가득 찼습니다.\n"); return; } else stack[++top] = item; } // 삭제 함수 element pop(..

프로그래밍/C 2023.02.21
728x90
반응형