프로그래밍/자료구조와 알고리즘 2022. 3. 18. 18:22
출처 1. 네이버 지식인 출처 2. https://xeriars.com/45 [Xeriars.com] [펌] 10000000까지의 소수 표와, 구하는 프로그램의 속도를 높여보자. 10000000까지의 소수는 직접 적어드릴수는 없습니다. 10000000까지의 소수의 개수는 정확하게 664579개입니다. 이 글에서는, 소수 구하는 프로그램 소스는 가르쳐 드리지 않습니다. 중간중간에 써드 xeriars.com 10000000까지의 소수는 직접 적어드릴수는 없습니다. 10000000까지의 소수의 개수는 정확하게 664579개입니다. 이 글에서는, 소수 구하는 프로그램 소스는 가르쳐 드리지 않습니다. 중간중간에 써드리는 소스 만으로도 충분히 짜맞추실수 있기 때문이죠. 소수 구하는 법을 아시는 분만 보시기 바랍니다..
프로그래밍/프로젝트 2022. 3. 18. 14:49
연결 리스트로 구현한 명단 관리 프로그램 1.구조체를 활용하여 명단에 기록될 구조를 생성 2.구현할 함수의 기본 틀을 세우기 3.프로그램 실행시 사용자에게 보이는 Text UI를 만들기 4.구조체 포인터를 이용하여 연결리스트 생성 5.연결리스트 검색과 지정 삭제 및 전체 삭제 기능 생성 6.헤드 리스트부터 꼬리 리스트까지 모든 내용을 출력하는 기능 구현 7.연결리스트 추가시 내림차순으로 정렬하여 추가 기능 구현 8.파일 저장 및 불러오기 기능 구현 구조체를 활용해서 리스트의 구조를 제작하고, 구현할 함수의 프로토타입을 구현했습니다. 함수의 프로토타입은 첫 번째로 초기화, 노드 삽입, 노드 출력, 검색, 모든 데이터 삭제를 우선적으로 구현했습니다. 사용자에게 프로그램을 사용할 수 있도록 Text UI를 구..
프로그래밍/자료구조와 알고리즘 2022. 1. 9. 02:09
#include #include #define SIZE 100 typedef struct GraphType { int n; // 정점의 개수 int Graph_Matrix[SIZE][SIZE]; }GraphType; int visited[SIZE]; void init(GraphType* g) { int row, col; g->n = 0; for (row = 0;row Graph_Matrix[row][col] = 0; } void insert_vertex(GraphType* g, int v) { if (((g->n) + 1) > SIZE) { fprintf(stderr, "Overflow"); return; } g-..
프로그래밍/자료구조와 알고리즘 2022. 1. 9. 02:06
#include #include #define MAX_SIZE 100 int heap_size; typedef struct Heap { int element[MAX_SIZE]; }heap; void init_(heap* h) { heap_size = 0; } void create(heap *h) { h = (heap*)malloc(sizeof(heap)); } void insert_max_size(heap* h, int item) { int temp; int index = ++(heap_size); if (heap_size == 0) { h->element[index] = item; } while (h->element[index/2] element[heap_size];..
프로그래밍/C언어 2022. 1. 9. 02:01
#include void main(void) { char* a; char b[10]; char* c[10]; char(*d)[10]; printf("%d\n", sizeof(a)); // 4 printf("%d\n", sizeof(*a)); // 1 printf("%d\n", sizeof(b)); // 10 printf("%d\n", sizeof(3[b])); // 1 printf("%d\n", sizeof(c)); // 40 printf("%d\n", sizeof(c[0])); // 4 printf("%d\n", sizeof(*c[1])); // 1 printf("%d\n", sizeof(d)); // 4 printf("%d\n", sizeof(d[0])); // 10 printf("%d\n", siz..
프로그래밍/C언어 2022. 1. 9. 01:59
#include #include #include #include int main() { pthread_t p_thread; pid_t pid; pid = fork(); if (pid == 0) { /* child process */ fork(); pthread_create(&p_thread, NULL, t_function, (void*)NULL); } fork(); printf("forked\n"); sleep(100); return 0; }
프로그래밍/자료구조와 알고리즘 2022. 1. 9. 01:57
#include int list[10] = {4, 2, 1, 59, 22, 44, 24 ,75, 8, 10}; void selection_sort(int list[]) { int min, i, j; int temp; /* 선택정렬은 인덱스 0~n-2까지 정렬하면 모두 정렬된다.*/ for (i = 0; i = 0 && list[j] > key; j--) list[j + 1] = list[j]; /* 레코드를 오른쪽으로 이동 */ list[j + 1] = key; } return; } void main(void) { selection_sort(list); for (int i = 0; i < 10; i++) printf("%d ", list[i]); int list2[10] = { 4, 2, 1, 59, 2..
프로그래밍/자료구조와 알고리즘 2022. 1. 8. 23:24
#include #include int SIZE = 10; struct bucket* hashTable; struct node { int key; int value; struct node* next; }; struct bucket { struct node* head; int count; }; struct node* createNode(int key, int value) { struct node* newNode; newNode = (struct node*)malloc(sizeof(struct node)); newNode->key = key; newNode->value = value; newNode->next = NULL; return newNode; } int hashFunction(int key) { r..