mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-18 19:34:25 +08:00
Retranslate the complete English edition from Simplified Chinese (#2010)
* Retranslate the complete English edition from Simplified Chinese * Polish three English explanations after reader-focused review
This commit is contained in:
@@ -6,24 +6,24 @@
|
||||
|
||||
#include "../utils/common.hpp"
|
||||
|
||||
/* Driver Code */
|
||||
/* Driver code */
|
||||
int main() {
|
||||
int num = 3;
|
||||
size_t hashNum = hash<int>()(num);
|
||||
cout << "Hash value of integer " << num << " is " << hashNum << "\n";
|
||||
cout << "Integer " << num << " has hash value " << hashNum << "\n";
|
||||
|
||||
bool bol = true;
|
||||
size_t hashBol = hash<bool>()(bol);
|
||||
cout << "Hash value of boolean " << bol << " is " << hashBol << "\n";
|
||||
cout << "Boolean " << bol << " has hash value " << hashBol << "\n";
|
||||
|
||||
double dec = 3.14159;
|
||||
size_t hashDec = hash<double>()(dec);
|
||||
cout << "Hash value of decimal " << dec << " is " << hashDec << "\n";
|
||||
cout << "Floating-point number " << dec << " has hash value " << hashDec << "\n";
|
||||
|
||||
string str = "Hello Algo";
|
||||
string str = "Hello 算法";
|
||||
size_t hashStr = hash<string>()(str);
|
||||
cout << "Hash value of string " << str << " is " << hashStr << "\n";
|
||||
cout << "String " << str << " has hash value " << hashStr << "\n";
|
||||
|
||||
// In C++, built-in std::hash() only provides hash calculation for basic data types
|
||||
// Hash calculation for arrays and objects needs to be implemented manually
|
||||
// C++ std::hash provides hashing for fundamental types and selected standard-library types
|
||||
// For arrays and unsupported object types, supply your own hash implementation
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user