본문 바로가기

자료구조/Linked List

list 만들기

#include <bits/stdc++.h>
#define l long long
#define INF 2e9
#define p pair<int,int>
#define vc vector<l>
using namespace std;

// 구조체를 사용하는 이유 : 메모리 최적화를 위해

struct List{        // 연결 리스트
    int value;      // 데이터 저장
    struct List *next;      // 다음 노드의 주소를 저장할 포인터
};

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

    struct List *head;
    head = (struct List *)malloc(sizeof(List));   // 메모리 동적할당
}

'자료구조 > Linked List' 카테고리의 다른 글

pirnt함수 구현  (0) 2022.03.22
Push함수 구현  (0) 2022.03.22