본문 바로가기

프로그래밍 언어/C

(11)
연결리스트 자료구조를 이용해서 구현한 다항식 계산기 #include #include typedef struct node { int coef; int exp; struct node* next; } Node; Node* newNode(int c, int e) { Node* p = (Node*)malloc(sizeof(Node)); p->coef = c; p->exp = e; p->next = NULL; return p; } Node* appendTerm(Node* k, int c, int e) { Node* t = newNode(c, e); Node* khead = newNode(0, 0); khead->next = k; while ((khead->next) != NULL) { khead = khead->next; } khead->next = t; retur..
자료구조/C) Tree 트리 구현 #define _CRT_SECURE_NO_WARNINGS #include #include #include typedef struct node { int data; struct node* left; struct node* right; } Node; typedef struct Tree { Node* root; }Tree; Node* initNode(int data) { Node* node = (Node*)malloc(sizeof(Node)); node->left = NULL; node->right = NULL; node->data = data; return node; } Tree* insertTree(Node* x, Node* y, Node* z, Tree* tr, int cnt) { Tree* subtr ..
[C/Error] 'for' loop initial declarations are only allowed in C99 or C11 mode[Note] use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code : for loop 에러 문제 해결 [Error] 'for' loop initial declarations are only allowed in C99 or C11 mode[Note] use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code mitosis-project/mitosis-workload-btree The BTree workload used for evaluation. Contribute to mitosis-project/mitosis-workload-btree development by creating an account on GitHub. github.com mitosis-project/mitosis-workload-hashjoin The Hash..
Socket Programming in C Client-Server 매커니즘 가정 : 서로 다른 네트워크 머신 (M1, M2) 가 상호 소통하는 프로그램을 만들고자 한다. 한 사람이 M1에서 첫번재 프로그램을 시작하면 이 프로그램은 M2에 있는 프로그램으로 메시지를 보낸다. 컴퓨터는 사람보다 빠르기 때문에 M1의 프로그램은 M2로 부터 응답을 받는데 몇 ms 밖에 걸리지 않는다. 두번째 프로그램은 M1으로부터 메시지를 받는데 몇 ms가 걸리고, 첫번째 프로그램이 아직 활성화가 되지 않았다고 결론을 내고 에러 메시지를 보여주고 나간다. 그럼 한쪽은 계속 프로그램을 실행시키더라도 상호소통할 수 없다. Socket 소캣의 개념 호스트의 네트워크 스택에 연결된 어플리케이션을 위한 인터페이스 소켓 API 32-bit 노드 주소 IP address 16-b..
C/C++ programming tutorial C/C++ programming tutorial 1. C Basics 1.1 source code #include int main() { printf("Hello world\n"); return 0; } 1.2 How to compile $ gcc hello.c -o hello gcc : 컴파일링 명령 hello.c : 소스 파일 이름 hello : 컴파일러로 만들어낸, 실행 가능한 파일 executable file 설정하지 않으면 a.out이 디폴트 1.3 How to execute ./hello 1.4 Data types 1.5 Variable Declaration example int length = 100; char num = '9' // The actual value is 57 (based on..
Hash Table : open addressing Hash Table : open addressing 성균관대학교 소프트웨어학과 조대호 교수님의 2020년도 2학기 알고리즘 수업을 듣고 수행한 과제입니다. open addressing 방식으로 충돌을 해결하는 Hash Table을 C로 구현하였습니다. problem • m = 37 • Hash functions (not exactly same as the previous open address hash functions) linear probing: h(k, i) = (h'(k) + i) mod m where, h'(k) = k mod m quadratic probing: h(k, i) = (h'(k) + c1i + c2i2 ) mod m where, h'(k) = k mod m, c1 = 1, c2 =..
분할 정복 Divide and Conquer 알고리즘으로 행렬 곱셈 matrix multiplication 풀기 분할 정복 Divide and Conquer : 행렬 곱셈 matrix multiplication problem Program the divide and conquer matrix multiplication using 1) standard algorithm 2) recursion For the two cases 1) and 2), Compare the number of computations (multiplication, addition, and subtraction) between 1), 2) cases. In the matrix computation of C = A×B, matrices A and B are filled with rand()%1000, execute srand(time(NULL)) f..
연결리스트 삽입, 삭제, 출력 Linked List insert delete print 구현하기 연결리스트 Linked List 성균관대학교 소프트웨어학과 조대호 교수님의 2020년도 2학기 알고리즘 수업을 들으며 수행한 과제입니다. problem Write functions which perform according to the following descriptions. The input to each function is a linked list of integers. a) insert - Inserts an integer x to the front of a linked list. e.g.) insert(lst, x) where lst is a pointer to a linked list and x is an integer. b) delete - Deletes 2 nd last integer x..