본문 바로가기

모각코/[2020_하계] 모각코

(18)
모각코 9일차 결과 (2020.07.27) BOJ 1927 최소 힙 문제 풀이 코드 (C Language) #include #include typedef struct heap { int *arr; int idx; } Heap; void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; } void heapSet(Heap *h, int size) { h->arr = malloc(sizeof(int)*size); h->idx = 0; } void push(Heap *h, int value) { h->arr[++(h->idx)] = value; int child = h->idx; int parent = child/2; while (child > 1 && h->arr[parent] > h->arr[chi..
모각코 9일차 계획 (2020.07.27) 알고리즘 공부하기 -- BOJ 1927 문제 풀기 --
모각코 8일차 결과 (2020.07.22) BOJ 11279 최대 힙 문제 풀이 코드 (C Language) #include #include typedef struct heap { int *arr; int idx; } Heap; void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; } void heapSet(Heap *h, int size) { h->arr = malloc(sizeof(int)*size); h->idx = 0; } void push(Heap *h, int value) { h->arr[++(h->idx)] = value; int child = h->idx; int parent = child/2; while (child > 1 && h->arr[parent] arr[ch..
모각코 8일차 계획 (2020.07.22) 알고리즘 공부하기 -- BOJ 11279 문제 풀기 --
모각코 7일차 결과 (2020.07.20) BOJ 17298 오큰수 문제 풀이 코드 (C Language) #include #include typedef struct stack { int *arr; int top; } Stack; void set(Stack *s, int n) { s->arr = malloc(sizeof(Stack)*n); s->top = -1; } void push(Stack *s, int value) { s->arr[++(s->top)] = value; } int pop(Stack *s) { s->arr[(s->top)--]; } int size(Stack *s) { return s->top+1; } int main(){ int N, *arr; Stack stack, result; scanf("%d", &N); set(&sta..
모각코 7일차 계획 (2020.07.20) 알고리즘 공부하기 -- BOJ 17298 문제 풀기 --
모각코 6일차 결과 (20200.07.15) BOJ 10845 큐 문제 풀이 코드 (C Language) #include #include typedef struct queue { int arr[10000]; int front; int back; } Queue; void queueSet(Queue *q) { q->front = -2; q->back = -2; } int size(Queue *q) { if (q->front == -2) { return 0; } else { return (q->back)-(q->front)+1; } } int empty(Queue *q) { if (size(q) == 0) { return 1; } else { return 0; } } int full(Queue *q) { if (size(q) == 10000) { ret..
모각코 6일차 계획 (2020.07.15) 알고리즘 공부하기 -- BOJ 10845 문제 풀기 --