일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- 컨테이너
- JSON
- Numpy
- C++
- 프로그래머스
- error
- nvidia-smi
- mysql
- C
- Linux
- 오류
- Python
- SSH
- pandas
- pytorch
- Selenium
- YOLO
- 기타 연주
- ubuntu
- OpenCV
- paramiko
- VS Code
- label
- Docker
- Visual Studio
- C#
- 핑거스타일
- 채보
- windows forms
- pip
- Today
- Total
목록C (7)
기계는 거짓말하지 않는다
배열에서 분할 정복을 이용하여 최댓값을 찾는 예시이다.배열을 왼쪽, 오른쪽 반씩 나누고 왼쪽 반에서 최댓값을 재귀적으로 찾는다.오른쪽도 마찬가지 방법으로 반복한다.이렇게 왼쪽, 오른쪽에서 찾은 최댓값을 비교하여 더 큰 값을 최댓값으로 설정한다.최솟값 찾기는 부호의 방향만 바꾸어주면 된다.#include int find_max_index(int arr[], int left, int right) { if (left == right) // 배열 길이 1 return left; int mid = (left + right) / 2; int left_max_index, right_max_index; left_max_index = find_max_index(arr, left, mi..
C언어 파일 존재여부 확인 Linux #include if( access( f_path, F_OK ) != -1 ) { // 파일 존재 } else { // 파일 없음 } stat 구조체 이용 #include bool exist_file (char *file_name) { struct stat buffer; return (stat (file_name, &buffer) == 0); } FILE 구조체 이용 #include FILE *file; if (file = fopen("temp.txt", "r")) { fclose(file); printf("파일 존재\n"); } else { printf("파일 없음\n"); }
오름차순 Top-Down Merge Sort #include #include #include #define MAX_SIZE 100 void merge(int arr[], int temparr[], int lo, int mid, int hi) { int i, j, k; for (k = lo; k hi) arr[k] = temparr[i++];// lo ~ mid 전 까지 남은 배열 복사 (right 파트 확인 끝) else if (temparr[j] < temparr[i]) arr[k] = temparr[j++]; else arr[k] = temparr[i++]; } } void mergeSort(int arr[], int temparr[], int lo, int hi) { if (hi

기본 이진 검색 트리 Declaration #include #include typedef enum bool{ false, true } bool; typedef enum eSelectMenu { selectInsert = 1, selectDelete, selectPrint, selectExit } eSelectMenu; typedef struct Node { int key_value; int count; struct Node* parent; struct Node* left; struct Node* right; } Node; Insert, Delete Node void InsertNode(Node** root, int value) { Node* ptr, * parent; parent = ParentSearc..

우선순위에 따른 정렬이 가능하다. Declaration #include #define MAX_Q_SIZE 101 typedef enum bool{ false, true }bool; typedef enum eSelectMenu { selectPush = 1, selectPop, selectPeek, selectExit } eSelectMenu; typedef struct ProcessInfo {// 프로세스 정보 저장을 위한 구조체 int pid; int remainingJob; bool initialize; }ProcessInfo; int queueElement = 0;//현재 큐에 있는 프로세스 수 ProcessInfo pQueue[MAX_Q_SIZE];// 우선순위 큐 bool IsNew(int); ..

element 한 자리가 항상 비게되지만, 재정렬 없이 큐 이용이 가능하다. First In First Out(FIFO) 구조 #include #define MAX_Q_SIZE 11// 원형 큐 이용 가능 크기 MAX_SIZE - 1 typedef enum eSelectMenu { selectAdd = 1, selectDelete, selectPrint, selectExit } eSelectMenu; typedef enum eBool { false, true } eBool; void Add(int [], int*, int*, int); int Delete(int [], int*, int*); eBool IsEmpty(int, int); eBool IsFull(int, int); int main(void)..

Last In First Out(LIFO) 구조 #include #define SIZE 100 typedef enum eSelectMenu { selectPush = 1, selectPop, selectPeek, selectSize, selectExit } eSelectMenu; typedef enum eBool{ false, true } eBool; int top = -1;// -1 or 0 int stack[SIZE]; void Push(int data) { stack[++top] = data; } int Pop() { return stack[top--]; } eBool IsEmpty() { return top == -1 ? true : false; } eBool IsFull() { return to..