호너씨와 조립제법과 수도미분
2022. 7. 10. 02:07
알고리즘 + 자료구조
어떤 값을 테일러 시리즈로 전개하고 전개식으로 계산하면, 그 끝에서는 원래 값과 일치할까? 하지만 극한에 이르러서는 차이가 생기고, 이 차이가 완전히 다른 결과를 낳는다면? 컴퓨터로 어떤 값을 계산할 때, double형의 데이터를 int형으로 형 변환될 때, 소수점 뒤에 값은 날아간다. 이때, 그 값은 chopping 된 값이다. 반대로, 사람이 chopping 할 수도 있는데, 유효숫자를 고려하지 않고, 그냥 편의대로 소수점 몇 번째 자리는 무시하는 것이다. 아무튼... 수치해석에서는 반올림할 때, 우리가 통상적으로 알고 있던 방식으로 하지 않고, 마지막 수가 5라면, 그 위의 자릿수가 짝수가 오도록 내림/올림 한다. 가령, 1.45를 반올림하면, 1.5이지만, 수치해석에서는 1.4로 한다. 만약에 1..
값 카테고리, 타입 카테고리
2022. 7. 4. 13:54
C++
lvalue - value category Any object in C++ that is named by the programmer is lvalue. lvalue is intialized with rvalue. the programmer should concern about the life. In other words, the programmer should be careful of the ownership of lvalue. lvalue has its ownership. rvalue - value category the programmer never have a chance to name rvalue. rvalue is never initialized. It itself is a value. 3, 4..
Type Category Testing_2(형 카 검-컴포지트 타입)
2022. 7. 4. 12:36
C++
Trait Effect is_reference Lvalue 또는 rvalue 레퍼런스 is_member_pointer 비정적 맴버에대한 포인터 is_arithmetic 정수형(bool, 문자형 포함) 또는 부동소수점 타입 is_fundamental void, 정수형(bool, 문자형 포함) 또는 부동소수점, std::nullptr_t is_scalar 정수형(bool, 문자형 포함) 또는 부동소수점, 열거형, 포인터, 맴버 포인터, std::nullptr_t is_object void, 함수, 레퍼런스를 제외한 모든 타입 is_compound is_fundermental의 반대: 배열, 열거형, 공용체, 클래스 함수, 레퍼런스, 포인터, 맴버 포인터 std::is_member_pointer::value ..
Template 가이드라인
2022. 7. 4. 00:53
C++
Function Templates Function templates define a family of functions for different template arguments.(함수 템플릿은 다양한 템플릿 인자에 대한 함수군을 정의한다.) When you pass arguments to function paramters depending on template parameters, function templates deduce the template parameters to be instantiated for the corresponding parameter types.(템플릿 파라미터에 종속된 함수 파라미터에 인자를 전달하면, 함수 템플릿은 템플릿 파라미터를 연역한 후, 해당하는 타입으로 인스턴스화 ..
Type Category Testing_1(형 카 검-내장타입)
2022. 7. 3. 13:43
C++
헤더는 유틸리티를 제공함. Traits Effect is_void void is_integral int류, bool, char, char16, char32_t, wchar_t it_array 내장 배열형, std::array는 클래스 형임 is_pointer 포인터형, 함수 포인터 포함, static 들어간 멤버 함수 포인터 is_null_pointer nullptr 형식 is_member_object_pointer non-static 멤버 is_member_function_pointer non-static 멤버 함수 포인터 is_lvalue_reference lvalue 레퍼런스 is_rvalue_reference rvalue 레퍼런스 is_enum 열거형 is_class 클래스/구조체 is_union..
ProtoType Factory
2022. 3. 8. 01:20
Design Pattern
#include using namespace std; class Monster { public: Monster(int ID) : ID{ ID }, type{ Monster::Type::unknown } {} virtual void Attack() = 0; virtual ~Monster() {} protected: enum class Type { unknown, slime, hog }; class Ability { public: int STR, AGI, INT; Ability() : STR{ 0 }, AGI{ 0 }, INT{ 0 }{} Ability(int STR, int AGI, int INT) : STR{ STR }, AGI{ AGI }, INT{ INT }{} }; int ID; Type type;..
[백준] 1967 트리의 지름
2021. 2. 20. 21:05
Problem set
1967번: 트리의 지름 파일의 첫 번째 줄은 노드의 개수 n(1 ≤ n ≤ 10,000)이다. 둘째 줄부터 n-1개의 줄에 각 간선에 대한 정보가 들어온다. 간선에 대한 정보는 세 개의 정수로 이루어져 있다. 첫 번째 정수는 간선이 연 www.acmicpc.net #include #include #include #include using namespace std; struct Edge { int to; int cost; Edge(int to, int cost) : to(to), cost(cost) { } }; vector a[10001]; bool check[10001]; int dist[10001]; void bfs(int start) { memset(dist,0,sizeof(dist)); memse..
[백준] 1167 트리의 지름
2021. 2. 20. 21:03
Problem set
1167번: 트리의 지름 트리가 입력으로 주어진다. 먼저 첫 번째 줄에서는 트리의 정점의 개수 V가 주어지고 (2≤V≤100,000)둘째 줄부터 V개의 줄에 걸쳐 간선의 정보가 다음과 같이 주어진다. (정점 번호는 1부터 V까지 www.acmicpc.net #include #include #include #include using namespace std; struct Edge { int to; int cost; Edge(int to, int cost) : to(to), cost(cost) { } }; vector a[100001]; bool check[100001]; int dist[100001]; void bfs(int start) { memset(dist,0,sizeof(dist)); memset(..