Menu
Coddy logo textTech

DoublyLinkedList Class

Coddy의 이중 연결 리스트 - 자료구조 시리즈 #6 코스 레슨 — 14개 중 4번째.

challenge icon

챌린지

쉬움

입력을 받지 않는 생성자를 포함하는 DoublyLinkedList 클래스를 작성하세요.

다음 세 개의 필드를 초기화하세요:

  • headnull로 설정합니다.
  • tailnull로 설정합니다.
  • count0으로 설정합니다.

이전 레슨에서 작성한 Node 클래스를 DoublyLinkedList 위에 유지하세요.

직접 해보기

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "doublylinkedlist.h"

int main() {
    DoublyLinkedList ll;
    DoublyLinkedList_init(&ll);
    char line[256];
    while (fgets(line, sizeof(line), stdin)) {
        line[strcspn(line, "\r\n")] = '\0';
        char* cmd = strtok(line, " \t");
        if (!cmd) continue;
        if (strcmp(cmd, "state") == 0) printf("%s %s %d\n", ll.head == NULL ? "true" : "false", ll.tail == NULL ? "true" : "false", ll.count);
    }
    return 0;
}

이중 연결 리스트 - 자료구조 시리즈 #6의 모든 레슨