본문 바로가기

<ALGORITHM>/NOTE9

20210208(월) 쓰레드 & 리스트 연습 #include #include #include #include // using std::thread; typedef struct _Book { unsigned int code; wchar_t name[20]; }Book; std::list bookList; void PushBook() { Book book; wprintf(L"책 데이터를 (코드 제목) 순서로 입력하세요.\n"); wprintf(L"데이터 : "); wscanf_s(L"%d %s", &(book.code), book.name, 20); bookList.push_back(book); } void PopBook() { bookList.pop_front(); } void PrintBooks() { wprintf(L" 코.. 2021. 2. 8.
20210203(수) 구조체 복습 #include #include #include typedef struct { wchar_t name[20]; wchar_t address[100]; unsigned int age; } Person; void PersonSwap(Person* a, Person* b) { Person temp = *a; *a = *b; *b = temp; } int main() { Person GildongHong; wcscpy(GildongHong.name, L"홍길동"); wcscpy(GildongHong.name, L"서울시 관악구 조원중앙로"); GildongHong.age = 18; Person* He = &GildongHong; wprintf(L"%s", *(He).name); wprintf(L"%.. 2021. 2. 3.
20210201(월) 자료구조 스택(Stack) 일시적으로 저장하기 위해 사용되는 자료구조 중 하나. 후입 선출(LIFO, Last In First Out) 순서로 데이터를 입출력 한다. 입력에 push, 출력에 pop 이란 용어를 사용한다. ▼ 배열로 만든 간단한 스택 #include const static int STACK_SIZE = 10; static int stackBuffer[STACK_SIZE] = { 0 }; static int currentIndex = 0; void Push(int value) { if (currentIndex < STACK_SIZE) { currentIndex++; } else { printf("Stack Is Overwrited.\n"); return; } stackBuffer[curre.. 2021. 2. 1.
20210127(수) std::sort() CPP 표준 라이브러리 에 정의되어 있는 함수. 기본적으로 오름차순이며 내림차순으로 지정할 수도 있다. ▼ 사용법 sort(v.begin(), v.end()); sort(v.begin(), v.end(), greater()); sort(v.begin(), v.end(), compare()); ▼ 예시 코드 #include #include #include void Print(int* arr) { printf("arr[] : "); for (int i = 0; i < 10; i++) printf("%d ", arr[i]); printf("\n"); } int main() { int arr[10] = { 3,4,2,4,5,1,2,3,5,0 }; Print(arr); std::sort(ar.. 2021. 1. 27.