Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://onlinegdb.com/jm_loagNp
- #include <stdio.h>
- unsigned int hash(const char *str) {
- unsigned int hashValue = 0;
- while (*str){
- hashValue = hashValue * 31 + *str++;
- }
- return hashValue;
- }
- int main() {
- char input[100];
- printf("String: ");
- scanf("%[^\n]", input);
- printf("Unique Identifier for '%s': %u", input, hash(input));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement