mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-01 18:55:23 +08:00
* feat(ko): add the complete Korean online edition * Use UTF-8 for Python CI output on Windows * Remove print-book promotion from the Korean site * fix(ko): preserve emphasis before Korean particles
30 lines
895 B
C++
30 lines
895 B
C++
/**
|
|
* File: built_in_hash.cpp
|
|
* Created Time: 2023-06-21
|
|
* Author: krahets ([email protected])
|
|
*/
|
|
|
|
#include "../utils/common.hpp"
|
|
|
|
/* 실행 코드 */
|
|
int main() {
|
|
int num = 3;
|
|
size_t hashNum = hash<int>()(num);
|
|
cout << "정수 " << num << " ; 해시값: " << hashNum << "\n";
|
|
|
|
bool bol = true;
|
|
size_t hashBol = hash<bool>()(bol);
|
|
cout << "불리언 값 " << bol << " ; 해시값: " << hashBol << "\n";
|
|
|
|
double dec = 3.14159;
|
|
size_t hashDec = hash<double>()(dec);
|
|
cout << "소수 " << dec << " ; 해시값: " << hashDec << "\n";
|
|
|
|
string str = "Hello 算法";
|
|
size_t hashStr = hash<string>()(str);
|
|
cout << "문자열 " << str << " ; 해시값: " << hashStr << "\n";
|
|
|
|
// C++의 내장 std::hash()는 기본 데이터 타입에 대한 해시값 계산만 제공한다
|
|
// 배열과 객체의 해시값 계산은 직접 구현해야 한다
|
|
}
|