반응형
[C++] 평균, 표준편차 구하기
Language/C++2022. 9. 23. 22:22[C++] 평균, 표준편차 구하기

평균 및 표준편차 계산 함수 #include // 평균 계산 함수 template double Mean(std::vector array) { double sum = 0.0; for (int i = 0; i < array.size(); i++) sum += array[i]; return sum / array.size(); } // 표준 편차 계산 함수 template double StandardDeviation(std::vector array) { double meanValue = Mean(array); // 배열 요소가 1개밖에 없을 때는 // NaN(숫자가 아님)이라는 의미로 // sqrt(-1.0) 을 반환 int size = array.size(); if (size < 2) { return sqrt..

[C++] Is the Point Inside the Polygon?
Language/C++2022. 9. 23. 22:19[C++] Is the Point Inside the Polygon?

point-in-polygon (PIP) “In computational geometry, the point-in-polygon (PIP) problem asks whether a given point in the plane lies inside, outside, or on the boundary of a polygon.” Wikipedia. 점이 다각형(Polygon) 내부에 있는지 확인하는 코드입니다. struct Point { int x; int y; }; bool InsidePolygon(int nvert, Point polygon[], int pointx, int pointy) { int i, j = 0; bool inside = false; for (i = 0, j = nvert - 1; i ..

[C++] DLL 동적 로딩
Language/C++2022. 9. 14. 20:51[C++] DLL 동적 로딩

DLL 동적 로딩 특정 폴더 내에 다수의 DLL 라이브러리 파일들을 로딩하기 위한 코드입니다. Header 파일 // dllload.h #include class DLLLoad { public: DLLLoad() {} ~DLLLoad() {} bool LoadLibrary(); bool FreeLibrary(); private: // DLL 폴더 경로를 설정합니다. const std::string DLL_DIR; // 로딩된 DLL 파일 경로들을 저장하고 관리합니다. std::list fileList; } C++ 파일 // dllload.cpp #include "dllload.h" #include #include const std::string DLLLoad::DLL_DIR = "C:\\dll\\"; D..

[C++] string을 이용한 File Path 분리 방법
Language/C++2022. 9. 5. 09:36[C++] string을 이용한 File Path 분리 방법

개요 string 형식의 파일 경로를 이용하여 File Path와 Name을 분리합니다. File Path와 File Name 분리 #include namespace using std; int main() { string pullPath = "c:\\test\\test.tif"; int find = pullPath.rfind("\\") + 1; string filePath = pullPath.substr(0, find); string fileName = pullPath.substr(find, pullPath.length() - find); cout

반응형
image