Код: Выделить всё
unsigned long long horner_hash(string str, int p, int m)
{
vector poly; /*TURN STRINGS INTO ASCII*/
for (int i = 0; i < str.size(); i++)
{
poly.push_back(static_cast(str[i]));
}
unsigned long long result = poly[0]; // Initialize
for (int i = 1; i < poly.size(); i++)
{
result = (result * p + poly[i]) % m;
}
return result;
}
hello
world
Хэндс
Функция
(они должны быть разделены)
Подробнее здесь: https://stackoverflow.com/questions/797 ... ash-code-c
Мобильная версия