gpt4 book ai didi

c++ - 如何在 C++ 中散列字符串?

转载 作者:搜寻专家 更新时间:2023-10-31 00:52:30 24 4
gpt4 key购买 nike

我目前正在学习哈希表。散列整数很容易,但我的任务是散列字符串。我给了字符串:

25674316-6058714                
56105665-7450612
96917015-1417157
48189873-3313151

我必须对它们进行散列以适应桶数组 [4]。我如何散列字符串?

最佳答案

随着standard libraries hash function :

std::string stringToHash = "25674316-6058714";
size_t result = std::hash<std::string>()(stringToHash);

关于c++ - 如何在 C++ 中散列字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51471310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com