목록2025/04 (9)
컴퓨터공학 💻 도서관📚
오늘 저는 우리나라의 헌법의 역사에 대해 발표할 것입니다. (발표) Today, I will present the history of our country's constitution. 좋은 요리는 좋은 식재료로부터 나옵니다. (요리) Good dishes come from good ingredients. (인그리디언트) 지금 우리에게 중요한 것은 포기하지 않는 정신입니다. (영화) What's important to us now is the spirit of not giving up.

객체 배열을 n 개 선언하면 객체가 n개 만들어지는게 아니고 객체 n개의 주소를 저장할 방만 생기는 것이다. 나중에 객체를 하나하나 만들어서 집어넣어야 한다 (객체를 넣지 않은 상태로 주소값을 확인해보면 NULL 값이 출력된다) public class Book { private String title; private String author; public Book() {} public Book(String title, String author) { this.title = title; this.author = author; } public String getTitle() { return title; } public void setTitle(String title) { this.title = ..
length : 배열의 길이를 알고 싶을 때length() : 문자열의 길이를 알고 싶을 때size() : Collection, 자료구조의 크기를 알고 싶을 때 public static void main(String[] args) { //Array int [] arr = new int[11]; System.out.println(arr.length); // 1 //String String str = "세상에서 제일가는 토테이토칩"; System.out.println(str.length()); // 2 //ArrayList ArrayList list = new ArrayList(); list.add(0, "123"); list.add(1, "234"); System.out.pr..

트리 자료구조 중에서 대표적인 트리인 이진 트리 예시 * 전위 순회 , 중위 순회 , 후위 순회 쉽게 구분하는 법 : root 가 몇번째 순서에 있는지 체크하면 편하다(전) left (중) right (후) : 그리고 left right 이 순서는 고정이다 전위 순회 : root left right중위 순회 : left root right후위 순회 : left right root #include #include // 노드 구조체 정의typedef struct Node { int data; struct Node* left; struct Node* right;} Node;// 노드 생성Node* createNode(i..
연결리스트로 구현한 큐 자료구조 #include #include // 노드 구조체 정의typedef struct Node { int data; struct Node* next;} Node;// 큐 구조체 정의typedef struct Queue { Node* front; Node* rear;} Queue;// 큐 초기화void init(Queue* q) { q->front = NULL; q->rear = NULL;}// 큐가 비었는지 확인int isEmpty(Queue* q) { return q->front == NULL;}// 데이터 삽입 (enqueue)void enqueue(Queue* q, int value) { Node* newNode = (Node*)..
연결리스트로 구현한 c언어 #include #include // 노드 구조체 정의typedef struct Node { int data; struct Node* next;} Node;// 스택 구조체 정의typedef struct Stack { Node* top;} Stack;// 스택 초기화void init(Stack* s) { s->top = NULL;}// 스택이 비었는지 확인int isEmpty(Stack* s) { return s->top == NULL;}// push: 스택에 데이터 삽입void push(Stack* s, int value) { Node* newNode = (Node*)malloc(sizeof(Node)); if (!newNode) { ..

아래 코드에서는 구조체 멤버변수 size 변수가 있어서 while문이 아닌 for문으로 코드를 짤 수 있 #include #include #define MAX_SIZE 100// 집합 구조체typedef struct { int elements[MAX_SIZE]; int size;} Set;// 집합에 원소 추가 (중복 방지)void addElement(Set *set, int elem) { for (int i = 0; i size; i++) { if (set->elements[i] == elem) return; // 이미 존재하면 추가하지 않음 } if (set->size elements[set->size++] = elem; }}// 합..
#include #include // 노드 정의typedef struct Node { int data; struct Node* next;} Node;// 원형 연결 리스트 구조체typedef struct { Node* head;} CircularLinkedList;// 리스트 초기화void initList(CircularLinkedList* list) { list->head = NULL;}// 노드 생성Node* createNode(int data) { Node* newNode = (Node*)malloc(sizeof(Node)); newNode->data = data; newNode->next = NULL; return newNode;}// 끝에 삽입void ..