크래프톤 정글

Tiny web server/* $begin tinymain *//* * tiny.c - A simple, iterative HTTP/1.0 Web server that uses the * GET method to serve static and dynamic content. * * Updated 11/2019 droh * - Fixed sprintf() aliasing issue in serve_static(), and clienterror(). */#include "csapp.h"void echo(int connfd);void doit(int fd);void read_requesthdrs(rio_t *rp);int parse_uri(char *uri, char *filename, char *..
링커 링킹(linking) 여러개의 코드와 데이터를 모아서 한 개의 파일로 만드는 작업. 로드타임, 실행시에도 수행될 수 있고 독립적인 컴파일을 가능하게 한다. 모듈을 나누고 하나의 모듈만 재 컴파일 하는 방식으로 사용된다. 링커를 이해해야 하는 이유 링커를 이해하면 큰 프로그램을 작성하는데 도움이 된다. 특히 맞지않는 라이브러리 버전때문에 링커 에러가 발생하는 경우는 링커가 참조를 해결해나가는 과정을 이해하고 있어야 해결할 수 있다. 위험한 프로그래밍 에러를 피할 수 있다. 전역변수를 중복해서 정의한 프로그램도 기본 설정의 경우 경고 메시지 없이 링커를 통과할 수 있다. 이런 에러를 예방하려면 링커를 이해해야 함. 링킹을 이해하면 어떻게 언어의 변수 영역 규칙이 구현되는지 이해할 수 있다. 컴파일러 드..
RB_Tree 1. RB_Tree 초기화 rbtree *new_rbtree(void) { rbtree *p = (rbtree *)malloc(sizeof(rbtree)); if (p == NULL) { perror("Failed to allocate memory for RB tree"); exit(EXIT_FAILURE); } // TODO: initialize struct if needed p->nil = (node_t *)malloc(sizeof(rbtree)); if (p->nil == NULL) { perror("Failed to allocate memory for sentinel node"); exit(EXIT_FAILURE); } p->nil->color = RBTREE_BLACK; p->ro..
자료구조 Binary Search Tree 기본 제공 함수 ////////////////////////////////////////////////////////////////////////////////// /* CE1007/CZ1007 Data Structures Lab Test: Section F - Binary Search Trees Questions Purpose: Implementing the required functions for Question 5 Implementing 'remove node' operation for BST*/ ////////////////////////////////////////////////////////////////////////////////// #includ..
자료구조 Stack and Queues 기본 제공 함수 ////////////////////////////////////////////////////////////////////////////////// /* CE1007/CZ1007 Data Structures Lab Test: Section C - Stack and Queue Questions Purpose: Implementing the required functions for Question 1 */ ////////////////////////////////////////////////////////////////////////////////// #include #include ///////////////////////////////////////..
알고리즘 1890 점프 # 실패코드! import sys from collections import deque input = sys.stdin.readline n = int(input()) arr = [] for _ in range(n): arr.append(list(map(int, input().split()))) queue = deque() # x,y 좌표값 추가 queue.append((0,0)) res = 0 while queue: cur_y, cur_x = queue.popleft() if cur_y == n-1 and cur_x == n-1: res += 1 continue distance = arr[cur_y][cur_x] new_x = cur_x + distance if distance !..
CSAPP 이기종 자료구조 (Heterogeneous) 이기종 자료구조란? 다른 여러가지의 데이터를 포함하고 있는 구조체(struct)와 공용체(Union)을 뜻한다. 구조체(struct) C 언어의 구조체(structure)는 다양한 데이터 타입의 멤버들을 하나로 묶어서 새로운 데이터 타입을 정의하는 데 사용. 자바의 class의 개념과 아주 약간 비슷함 구조체의 offset 각 구조체의 필드값에 따른 byte 용량으로 정한다. char = 1byte, long = 8byte... 공용체(union) 말 그대로 필드값의 가장 큰 Byte만큼만 메모리를 할당하고, 그 메모리를 모든 필드값들과 공유하며 사용함. 메모리를 효율적으로 사용할 수 있지만, 한번에 하나의 필드값밖에 할당할 수 없어 지금은 잘 사용..
1. 2637 장난감 조립 import sys from collections import deque input = sys.stdin.readline # 위상정렬 후 정렬된 결과값 반환 def topological_sort(): result = [] queue = deque() for i in range(1, n+1): if in_degree[i] == 0: queue.append(i) while queue: current = queue.popleft() result.append(current) for index, value in graph[current]: in_degree[index] -= 1 if in_degree[index] == 0: queue.append(index) return result d..
1. 1916 최소비용 구하기 import math import sys import heapq input = sys.stdin.readline def make_graph(vertices, edges): # 빈 그래프 생성 graph = [[] for _ in range(vertices+1)] for i in range(edges): # 그래프에 값 추가 start_vertex, arrival_vertex, cost = map(int, input().split()) graph[start_vertex].append((cost, arrival_vertex)) return graph def dijkstra(graph, start_vertex): queue = [] # 거리를 저장할 리스트 선언 distances..
1. 11725 트리의 부모찾기 import sys from collections import deque input = sys.stdin.readline result = [] def bfs(visited, result): queue = deque([1]) visited.add(1) while queue: vertex = queue.popleft() for neighbor in graph[vertex]: if neighbor not in visited: queue.append(neighbor) result[neighbor] = vertex visited.add(neighbor) return result n = int(input()) graph = [[] for _ in range(n + 1)] for i ..
전낙타
'크래프톤 정글' 태그의 글 목록 (2 Page)