#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// 哈希函数
unsigned int hash_function(const char *str) {
unsigned int hash = 0;
while (*str) {
hash = (hash * 31 + *str) % 1000;
str++;
}
return hash;
}
int main() {
const char *str1 = "Hello";
const char *str2 = "World";
unsigned int hash1 = hash_function(str1);
unsigned int hash2 = hash_function(str2);
printf("String: %s, Hash: %u\n", str1, hash1);
printf("String: %s, Hash: %u\n", str2, hash2);
return 0;
}