c언어
-
[자료구조] 1-3. 알고리즘 예시 & 재귀 함수 (C/C++)50 shades of ZZ/C(++) 자료구조 마스터 2023. 9. 27. 21:38
[알고리즘 예시] Selection Sort 선택 정렬 문제 : Sort a set of n ≥ 1 integers in non-decreasing order 방법 : from those integers that are currently unsorted, find the smallest and place it next in the sorted list pseudocode algorithm for(i = 0; i < n - 1; i++){ 1. list[i]와 list[n-1] 비교 / 가장 작은 값은 list[min]에 대입 2. list[i]와 list[min] 교환 } #define SWAP(x, y, t) \\ ((t)=(x), (x)=(y), (t)=(t)) void sort(int list[],..
-
[자료구조] 1-2. 동적 메모리 Dynamic memory (C/C++)50 shades of ZZ/C(++) 자료구조 마스터 2023. 9. 27. 01:42
Dynamic memory 동적 메모리 static / dynamic memory sray : pointer constant ( pointer) pary : pointer variable void Pointer_Test(void){ int sary[5]; int *pary = NULL; pary = (int *)malloc(5 * sizeof(int)); } dynamic memory allocation 프로그램 실행 전에 필요한 메모리를 알 수 없는 경우 동일한 일을 반복하는 프로그램에서 같은 이름으로 서로 다른 크기의 메모미를 매번 필요로 하는 경우 // allocation 함수 (형변환하여 호출) void *malloc(size_t size); // 전체 크기 void *calloc(size_t n..
-
[자료구조] C/C++ 자료구조 마스터(?)를 위한 요점 정리50 shades of ZZ/C(++) 자료구조 마스터 2023. 9. 26. 22:52
이번 학기 자료구조 수업을 들으며 강의 내용을 정리합니다! 목차는 아래와 같으며 순차적으로 추가될 예정입니다. 모든 내용은 강의자료를 토대로 정리되며, 해당 강의자료는 아래 교재를 기반으로 합니다. https://product.kyobobook.co.kr/detail/S000003052316 Fundamentals of Data Structures in C | Ellis Horowitz - 교보문고 Fundamentals of Data Structures in C | product.kyobobook.co.kr +) 개인 공부용이라 오류가 있을 수 있음 1. Introduction 2023.09.26 - [50 shades of ZZ/C(++) 자료구조 마스터] - [자료구조] 1-1. 포인터 Pointe..
-
[자료구조] 1-1. 포인터 Pointer (C/C++)50 shades of ZZ/C(++) 자료구조 마스터 2023. 9. 26. 22:33
pointer 포인터 (= pointer variable) 어떤 변수의 메모리 주소를 저장하는 변수 pointer constant : 메모리 주소에 대응하는 값 pointer가 NULL일 경우, 해당 pointer는 아무것도 가리키지 않음을 의미 (실제 값은 0) x; x라는 이름의 memory storage : storage 크기는 에 따름 (위치 : &x) *p; type이 인 memory storage의 주소를 저장하는 storage의 이름 (= pointer variable) int main(){ int x = 9, *p; p = &x; } // storage의 크기는 컴퓨터시스템에 따라 32 또는 64 bit pointer 예시 *(pointer) : pointer가 가리키는 variable (..